自定义过渡时的黑色背景
Black Backgroud while custom transition
我想使用自定义过渡更改视图。它正在运行,但背景是 dark/black,所以它看起来有点奇怪。
我尝试添加
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)
要在转换期间更改背景颜色,可以是 window 本身:
UIApplication.shared.keyWindow?.backgroundColor = UIColor.white
根视图控制器:
if let root = UIApplication.shared.keyWindow?.rootViewController as? YourRootViewController {
root.view.backgroundColor = UIColor.black
}
呈现视图控制器或转换的容器视图。
我想使用自定义过渡更改视图。它正在运行,但背景是 dark/black,所以它看起来有点奇怪。
我尝试添加
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)
要在转换期间更改背景颜色,可以是 window 本身:
UIApplication.shared.keyWindow?.backgroundColor = UIColor.white
根视图控制器:
if let root = UIApplication.shared.keyWindow?.rootViewController as? YourRootViewController {
root.view.backgroundColor = UIColor.black
}
呈现视图控制器或转换的容器视图。