See the pic below, i presented a viewcontroller in my app, here comes 3 layers on screen:
My question is, shouldn't the first layer be a blurred screen shot of a previously running app, why it's black? can i set the color?
Edit: it turns out the first layer is not provided by system, but simply app's key window background! see my answer below
I managed to solve it by setting the key window background color, eg:
// inside appDelegate's didFinishLaunchingWithOptions
// The first layer will be white now
window?.backgroundColor = UIColor.white
In the viewWillAppear
of the root view controller, you need to reset background color of it by put the code bellow:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.view.backgroundColor = .white
}
In put this at where you push the new view controller:
self.navigationController?.pushViewController(anotherVC, completion: {
self.view.backgroundColor = .black
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.