快速翻转动画翻转整个视图而不是子视图 [英] flip animation in swift flips whole view not subviews

查看:130
本文介绍了快速翻转动画翻转整个视图而不是子视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在两个子视图之间切换,因为我正在使用翻转动画,但它会翻转整个屏幕而不是子视图。这是我用来翻转的代码:

I need to switch between two subviews, for that I am using flip animation, but it flips whole screen not subview. Here is the code I used to flip:

UIView.transitionFromView(frontView, toView: backView, duration: 1, options: UIViewAnimationOptions.TransitionFlipFromRight | UIViewAnimationOptions.ShowHideTransitionViews, completion: nil)

我在StoryBoard中创建了frontView和backView,并且backView最初隐藏。

I have created frontView and backView in StoryBoard, and backView hidden initially.

请帮我翻转子视图。

推荐答案

这个问题很老,但它可以帮助某人。如果你想翻转你的self.view使用它:

This question is old, but it can help someone. If you want to flip your self.view use it:

UIView.transitionWithView(self.view, duration: 0.8, options: UIViewAnimationOptions.TransitionFlipFromRight | UIViewAnimationOptions.ShowHideTransitionViews, animations: {
            self.view.addSubview(newView)
            }, completion:  { finished in
                //HERE you can remove your old view 
             oldView.removeFromSuperview()
        })

这篇关于快速翻转动画翻转整个视图而不是子视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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