How to access main window try this one but it is not working for me :
if let app = UIApplication.shared.delegate as? AppDelegate, let window = app.window {
window.addSubview(offerView)
}
also i try with this way but no luck for me :
if let window = UIApplication.shared.windows.first {
window.addSubview(offerView)
}
Note: keyWindow
work for me but Using keyWindow
can return a keyboard or UIAlertView window, which lie above my application window.
Here is existing question i found but that answer not working for me
How do I get the keyWindow reference in a swift app?
on my application one offer view appear from bottom of the page. that offer will be shown half of the screen