Apple 如何制作 iBooks 2 抽认卡的动画?
我正在尝试使用以下方法从一个 UIView
转换到另一个。
[UIView transitionFromView:self.frontsideCardView
toView:self.backsideCardView
duration:kFlipCardAnimationDuration
options:UIViewAnimationOptionTransitionFlipFromTop
completion:completion];
问题是,当我打开两个视图上的 CALayer
阴影和圆角时,动画会变得滞后。因此,我查看了 Apple 应用程序,看看它们是否做了类似的事情,我发现 iBooks 2 应用程序确实如此。你可以在那里学习抽认卡,如果你点击一张卡片,它就会顺利翻转。据我所知,他们还使用圆角和阴影。
我注意到,在我的动画中,翻转时视图会逐渐变黑 - 在 iBooks 中不会发生这种情况:
(例如,我从视图中删除了所有内容,否则它只是以 10 fps 的速度播放动画)
苹果公司是如何制作出如此流畅的动画的?
I'm trying to transition from one UIView
to another by using
[UIView transitionFromView:self.frontsideCardView
toView:self.backsideCardView
duration:kFlipCardAnimationDuration
options:UIViewAnimationOptionTransitionFlipFromTop
completion:completion];
The problem is that the animation becomes laggy when I turn on CALayer
shadows and rounded corners on the two views. So I looked around the Apple apps to see if they did something similar and I found that the iBooks 2 app does. You can learn flashcards there and if you tap a cards, it flips over smoothly. And from what I can see, they also use rounded corners and shadows.
What I noticed was that in my animation, the views fade to black while flipping - in iBooks this does no happen:
(for the example I removed everything from the view, otherwise it's just animating at 10 fps)
Any ideas what Apple did to create such a smooth animation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我敢打赌,他们使用的图像是在普通的旧视图上绘制的。
最简单、最快的方法。
They're using images painted on plain old views I'd bet.
Simplest, fastest way to do it.
有一个与 Lion 中滑动相关的示例,您可以根据自己的使用进行调整:https: //developer.apple.com/library/mac/samplecode/PictureSwiper。基本上,您拍摄页面之前和之后的页面的照片,将它们放入位于您的页面顶部的隐藏视图中的图层中,然后在滑动期间显示视图并为图层设置动画。滑动完成后,您可以隐藏视图并重新缓存图像。整个过程在 ios 中可能比在 osx 中更容易实现。
There is an example that pertains to swiping in Lion that you can probably adapt for your use: https://developer.apple.com/library/mac/samplecode/PictureSwiper. Basically, you take a picture of the pages before and after yours, put them in layers in a hidden view that is on top of yours, and then show the view and animate the layers during swiping. When swiping is complete, you hide the view and recache the images. This whole process will probably easier to implement in ios than osx.