我想通过自定义过渡来更改 View 。它可以工作,但背景是暗/黑色的,所以看起来有点奇怪。
我尝试添加
self.window!.backgroundColor = UIColor.white
给代表,但这并不能解决问题。
这是我的转换代码
let homeView = self.storyboard?.instantiateViewController(withIdentifier: "ViewController") as! ViewController
let transition = CATransition()
transition.duration = 2.3
transition.type = CATransitionType.reveal
transition.subtype = CATransitionSubtype.fromLeft
view.window!.layer.add(transition, forKey: "transition")
self.dismiss(animated: false, completion: nil)
present(homeView, animated: false, completion: nil)
最佳答案
要在转换期间更改背景颜色,可以是窗口本身:
UIApplication.shared.keyWindow?.backgroundColor = UIColor.white
Root View Controller :
if let root = UIApplication.shared.keyWindow?.rootViewController as? YourRootViewController {
root.view.backgroundColor = UIColor.black
}
呈现 View Controller 或转换的容器 View 。
关于ios - 自定义过渡时的黑色背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55479946/