我现在正在学习Three20,并希望自己实施facebook iphone客户端作为练习。 在facebook iphone客户端的主屏幕中,搜索栏下面有几个项目。我认为它是滚动视图和页面控件的组合。当您在某个项目上单击很长时间时,它看起来就像您在iPhone的应用程序图标上执行的操作一样:您可以将项目拖动到新位置甚至删除添加的项目。 所以我的问题是:
谢谢!
答案 0 :(得分:0)
实现您正在讨论的主屏幕的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];
}
最后一个块是负责动画效果的那个。