UIView 垂直翻转动画 [英] UIView vertical flip animation
问题描述
我有一个带有 UIViewAnimationTransitionFlipFromRight
的 iOS UIView.不过我需要它垂直翻转.页面卷曲过渡不会削减它.我认为这需要一些自定义的东西.
I have an iOS UIView with UIViewAnimationTransitionFlipFromRight
. I need it to flip vertically though. The page curl transition won't cut it. I assume this will require something custom.
有什么想法吗?
推荐答案
从 iOS 5.0 开始,无需编写自己的 Core Animation 转换来进行垂直翻转.只需使用 UIKit 的 UIViewAnimationOptionTransitionFlipFromTop
和 UIViewAnimationOptionTransitionFlipFromBottom
转换,所有这些都变成了一个单一的方法调用.
As of iOS 5.0, there's no need to write your own Core Animation transformation to do vertical flips. Just use UIKit's UIViewAnimationOptionTransitionFlipFromTop
and UIViewAnimationOptionTransitionFlipFromBottom
transitions, and all this stuff becomes a single method call.
这些行为类似于 UIViewAnimationOptionTransitionFlipFromLeft
和 UIViewAnimationOptionTransitionFlipFromRight
(自 iOS 2.0 以来一直存在).
These behave analagously to UIViewAnimationOptionTransitionFlipFromLeft
and UIViewAnimationOptionTransitionFlipFromRight
(which have been around since iOS 2.0).
示例用法:
[UIView transitionFromView:viewToReplace
toView:replacementView
duration:1
options:UIViewAnimationOptionTransitionFlipFromBottom
completion:nil];
上面的代码会垂直翻转viewToReplace
的superview.在动画的中间点,当父视图垂直于屏幕并因此不可见时,viewToReplace
被 replacementView
替换.
The above code will vertically flip the superview of viewToReplace
. At the halfway point in the animation, at the instant when the superview is perpendicular to the screen and thus invisible, viewToReplace
gets replaced by replacementView
.
就这么简单.
这篇关于UIView 垂直翻转动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!