Three20 TTLlauncher 动画/过渡
我目前使用 Three20 TTLauncher 作为我的应用程序的基础。
然而,当点击 TTLaunchItem 时,它会跳转到映射的 URL。
有什么方法可以使用 facebook 应用程序使用的相同“扩展”动画/过渡吗?
I'm currently using the Three20 TTLauncher as a base for my app.
However when tapping on a TTLaunchItem, it jumps to the mapped URL.
Is there any way that I can use the same "expanding" animation/Transition that the facebook app uses?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我假设您在 TTLauncherView 中打开 URL,如下所示:
要打开带有动画的 url,您必须为视图设置动画,然后打开 URL,如下所示。
首先,您需要一个新变量来保存您的 URL。转到您的 LauncherView.h 文件并定义一个新的
NSString *_urlToOpen;
回到您的 .m 文件,我们还需要另外 2 个方法。一个用于动画部分(仅对视图进行动画处理),另一个用于动画完成时调用。
我先发布动画的代码,稍后再解释。
首先,我们将 userInteractionEnabled 设置为 NO,以便用户在动画运行时无法点击任何按钮。然后我们从 TTNavigator 获取要打开动画的 viewController 并将其添加到实际视图(启动器视图)中。
将新视图的框架定义到屏幕边界,并将其缩小到屏幕中间的一个非常小的尺寸。现在我们设置动画以将视图缩放到其原始大小(屏幕边界)并使用 DidStopSelector 启动动画。
DidStopSelector 看起来像这样:
第一行是不言自明的。然后我们只从超级视图中删除视图并打开我们的 URL,但没有任何过渡动画。
最后编辑您的
- (void)launcherView:(TTLauncherView*)launcher didSelectItem:(TTLauncherItem*)item
方法以将 URL 保存在新变量中并调用 animateTransition 方法。另一个方向也是如此,但您必须关心如果用户点击导航栏上的后退按钮会发生什么。正常行为是使用标准幻灯片动画恢复动画。
此答案基于 Three20 Google Groups 的论坛主题。请在此处找到它。
I assume you are opening your URL in your TTLauncherView like this:
To open a url with a animation you have to animate the view in and then open the URL like the following.
First you need a new variable to hold your URL. Go to your LauncherView.h file and define a new
NSString *_urlToOpen;
Back in your .m file we need 2 more methods. One for the animation part (just animating the view in) and another one, which gets called, when the animation has finished.
I post the code for the animation first and explain it later on.
First we set userInteractionEnabled to NO so the user is not able to tap any buttons while the animation runs. Then we get the viewController we want to open animated from the TTNavigator and add this to the actual view (the Launcher View).
Define the frame of our new view to the screen bounds and scale it down to a very small size in the middle of the screen. Now we set up the animation to scale the view up to its original size (the screen bounds) and start the animation with a DidStopSelector.
The DidStopSelector looks like this:
The first line is self-explanatory. Then we only remove the view from the superview and open our URL but without any transition animation.
Finally edit your
- (void)launcherView:(TTLauncherView*)launcher didSelectItem:(TTLauncherItem*)item
method to save the URL in your new variable and the call the animateTransition method.The same works in the other direction, but you have to care about what happens if your user taps the back button on your navigation bar. Normal behavior is to animate back with the standard slide animation.
This answer is based on a forum thread over at the Three20 Google Groups. Find it here.
我必须在我的一个项目中写一些类似的东西。
参见 https://github.com/aporat/TTLauncherView_ExpandViewTransitions
这个示例项目还包含了返回时的缩小效果到启动器视图& Facebook 启动器后退按钮
I had to write something similar in one of my projects.
See https://github.com/aporat/TTLauncherView_ExpandViewTransitions
This sample project also includes the shrinking effect when going back to the launcher view & the Facebook launcher back button