flip animation in swift flips whole view not subviews

被刻印的时光 ゝ 提交于 2019-11-30 19:22:34

问题


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)

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

Please help me too flip only the subviews.


回答1:


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()
        })



回答2:


finally i got fix for this, we need to add frontView and backView to another View(container) not for self.view, then container will flip.



来源:https://stackoverflow.com/questions/27120237/flip-animation-in-swift-flips-whole-view-not-subviews

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!