In my app I want to create a new UIWindow over the main UIWindow, And I wrote as following, but it don\'t works.
first, i create a UIWindow as the
class ViewController: UIViewController {
var coveringWindow: UIWindow?
func coverEverything() {
coveringWindow = UIWindow(frame: (view.window?.frame)!)
if let coveringWindow = coveringWindow {
coveringWindow.windowLevel = UIWindowLevelAlert + 1
coveringWindow.isHidden = false
}
}
}
According to the documentation, to receive events that do not have a relevant coordinate value, such as keyboard entry, make it key instead of merely ! isHidden:
coveringWindow.makeKeyAndVisible()
You can even control the transparency of its background, for a smoke effect:
coveringWindow.backgroundColor = UIColor(white: 0, alpha: 0.5)
Note that such window needs to handle orientation changes.