UIView 垂直翻转动画 [英] UIView vertical flip animation

查看:32
本文介绍了UIView 垂直翻转动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有 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 的 UIViewAnimationOptionTransitionFlipFromTopUIViewAnimationOptionTransitionFlipFromBottom 转换,所有这些都变成了一个单一的方法调用.

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.

这些行为类似于 UIViewAnimationOptionTransitionFlipFromLeftUIViewAnimationOptionTransitionFlipFromRight(自 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.在动画的中间点,当父视图垂直于屏幕并因此不可见时,viewToReplacereplacementView 替换.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆