我想通过自定义转换来更改视图。它可以正常工作,但背景色是深/黑色,因此看起来有点奇怪。
我尝试添加
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)
答案 0 :(得分:0)
要在过渡期间更改背景颜色,可以是窗口本身:
UIApplication.shared.keyWindow?.backgroundColor = UIColor.white
根视图控制器:
if let root = UIApplication.shared.keyWindow?.rootViewController as? YourRootViewController {
root.view.backgroundColor = UIColor.black
}
当前视图控制器或过渡的容器视图。