淡出UIView和切换UIView [英] Fade UIView and Switch UIView
本文介绍了淡出UIView和切换UIView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我从一个UIView切换到另一个UIView: self.view = MyView;
如何淡出一个视图到我的 MySecondView
?
This is how I switch from one UIView to another UIView: self.view = MyView;
How would I fade out a view to my MySecondView
?
推荐答案
您可以使用UIView的构建过渡代码, 。
You can use UIView's build in transition code to cross dissolve between them.
[UIView transitionFromView:self.view toView:MySecondView duration:0.25 options:UIViewAnimationOptionTransitionCrossDissolve completion:^(BOOL finished) {
// What to do when its finished.
}];
您也可以使用类似这样的常规动画选项。我没有测试这个代码,因为我不在Xcode前面,但我一直使用它的标签和没有默认动画的东西。
You can also use the regular animation options with something like this. I haven't tested this code as I'm not in front of Xcode but I use it all the time for labels and things without default animations.
[UIView animateWithDuration:0.25 animations:^{
[self.view setAlpha:0.0];
self.view = mySecondView;
[self.view setAlpha:1.0];
}];
这篇关于淡出UIView和切换UIView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文