快速翻转动画翻转整个视图而不是子视图
问题描述:
我需要在两个子视图之间切换,因为我正在使用翻转动画,但它会翻转整个屏幕而不是子视图。这是我用来翻转的代码:
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()
})