关于facebook iphone客户端实现的问题

时间:2011-05-24 09:17:23

标签: ios three20

我现在正在学习Three20,并希望自己实施facebook iphone客户端作为练习。 在facebook iphone客户端的主屏幕中,搜索栏下面有几个项目。我认为它是滚动视图和页面控件的组合。当您在某个项目上单击很长时间时,它看起来就像您在iPhone的应用程序图标上执行的操作一样:您可以将项目拖动到新位置甚至删除添加的项目。 所以我的问题是:

  1. 物品的控制是什么,定制TTButton?以及如何实现动画,特别是拖动?
  2. 当您点击一个项目时,会出现一个新视图。如何实现动画,如阴影?
  3. 谢谢!

1 个答案:

答案 0 :(得分:0)

实现您正在讨论的主屏幕的Three20类是TTLauncherView

  1. 它包含TTLauncherButtons作为其内部元素,直接来自UIControl(因为UIButton也是如此)。如果你想自己实现(不是简单地使用)拖动动画,你应该研究src/Three20UI/Sources/TTLauncherView.m中可用的源代码,这里解释起来非常复杂,因为涉及很多方法。我建议从buttonTouchedDown:withEventstartDraggingButton:开始,然后按照那里的流程进行操作。如果您对编辑模式动画感兴趣,请检查wobble选择器。

  2. 对于选择按钮时的动画,这不是Three20特有的。您可以在src/Three20UINavigator/Sources/TTBaseNavigationController.m中查看他们如何执行此操作,搜索pushViewController:animatedWithTransition;

  3. 这是代码,供您参考:

    - (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];
    } 
    

    最后一个块是负责动画效果的那个。