IOS12 翻转过渡方式:无法正常工作



开发一个重型UI应用程序时,QA团队报告说,我们视图的"翻转"停止正常工作。紫苑测试问题 我们注意到此问题仅适用于 IOS12。

如果您测试我添加的代码,即使是具有两个只有背景颜色的视图的非常简单的示例,您也会在transitionWith中看到:正在显示的视图没有动画,只是被隐藏了。隐藏的视图正在正确进行动画处理。

同样,这只是IOS12中的一个问题,并且在过渡中工作正常从:到:

class ViewController: UIViewController {
var firstView: UIView!
var secondView: UIView!
var containerView: UIView!
var showBackView = false
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
//containerView = UIView(frame: CGRect(x: 32, y: 32, width: 128, height: 128)) - // transitionFrom:To Code
// General code
firstView = UIView(frame: CGRect(x: 32, y: 32, width: 128, height: 128))
secondView = UIView(frame: CGRect(x: 32, y: 32, width: 128, height: 128))
firstView.backgroundColor = UIColor.red
secondView.backgroundColor = UIColor.blue

// transitionFrom:To Code
//        containerView.addSubview(firstView)
//        containerView.addSubview(secondView)
//        view.addSubview(containerView)

// transitionWith: Code
view.addSubview(firstView)
view.addSubview(secondView)
self.firstView.isHidden = false
self.secondView.isHidden = true
// General code
let button = UIButton(frame: CGRect(x: 200, y: 200, width: 50, height: 50))
button.addTarget(self, action: #selector(tappedButton), for: .touchUpInside)
button.backgroundColor = UIColor.green
view.addSubview(button)
}
@objc func tappedButton(sender: UIButton!) {
flip()
}
func flip() {
let transitionOptions: UIView.AnimationOptions = [.transitionFlipFromRight, .showHideTransitionViews]
// transitionFrom:To Code
//        let toView = showBackView ? firstView : secondView
//        let fromView = showBackView ? secondView : firstView
//        UIView.transition(from: fromView!, to: toView!, duration: 1.0, options: transitionOptions, completion: nil)
// transitionWith: Code
print("******************")
UIView.transition(with: firstView, duration: 3.0, options: transitionOptions, animations: {
print(self.firstView.isHidden)
print(self.secondView.isHidden)
self.firstView.isHidden = !self.firstView.isHidden
})
print("----------------------")
UIView.transition(with: secondView, duration: 3.0, options: transitionOptions, animations: {
print(self.firstView.isHidden)
print(self.secondView.isHidden)
self.secondView.isHidden = !self.secondView.isHidden
})
}
}

这是一个已知问题吗?我在网上找不到任何参考资料;不幸的是,这打破了旧的动画。

我已经通过使用transitionFrom:To解决了这个问题:但这不是一个解决方案,这是一个解决方法。 过渡:仍然在 IOS12 上刹车!

最新更新