實現你所說的主屏幕的Three20類是TTLauncherView
。
它包括TTLauncherButtons
作爲其內部元件,直接從該UIControl
派生(如UIButton
也一樣)。如果您想實現自己(而不是簡單地使用)拖動動畫,您應該研究src/Three20UI/Sources/TTLauncherView.m
中提供的源代碼,由於涉及許多方法,因此這裏解釋起來相當複雜。我建議從buttonTouchedDown:withEvent
和startDraggingButton:
開始,並按照從那裏的流程。如果您對編輯模式動畫感興趣,請選擇wobble
選擇器。
至於動畫當你選擇一個按鈕時,這不是特定於Three20。你可以學習他們如何在src/Three20UINavigator/Sources/TTBaseNavigationController.m
中執行此操作,搜索pushViewController:animatedWithTransition
;
這是代碼,供大家參考:
- (void)pushViewController: (UIViewController*)controller
animatedWithTransition: (UIViewAnimationTransition)transition {
[self pushViewController:controller animated:NO];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:TT_FLIP_TRANSITION_DURATION];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(pushAnimationDidStop)];
[UIView setAnimationTransition:transition forView:self.view cache:YES];
[UIView commitAnimations];
}
最終塊是一個負責的動畫效果。
感謝您的快速響應!我會盡快嘗試。我可以問一下:你怎麼知道我剛剛在三二十中提到的示例項目? – scorpiozj 2011-05-24 12:54:39
不客氣。我在我的兩個項目中使用了three20,你知道...... – sergio 2011-05-24 13:06:34
TTLauncherView是我需要的!非常感謝 – scorpiozj 2011-05-24 13:07:31