Reputation: 91
I have an app that presents modally View Controllers, I have a standard ViewController and an UIAlertController in different UIWindows, the main with normal UIWindowLevel priority and the Alert window with Alert UIWindowLevel priority, because I want to always have the alert on top of whatever ViewController I present modally on the main UIWindow (AppDelegates reference). I also have another UIWindow with Status Bar priority, for moments when I want for sure to have a different ViewController on top of everything. So when I present the UIWindow with a Alert UIWIndowLevel priority and after I present a different window with Status Bar UIWIndowLevel the alert in the Alert Window is displaying on top of the Status Bar window. Is there a reason for that?
An example app screenshot I built to test in
Upvotes: 1
Views: 6975
Reputation: 91
So, I was looking at some of the many SOs opened and saw this answer: https://stackoverflow.com/a/24262942/6784707
I printed the values of (UIWindowLevelNormal, UIWindowLevelAlert, UIWindowLevelStatusBar) are (0.0, 2000.0, 1000.0). But Apple's documentations states that:
let UIWindowLevelNormal: UIWindowLevel
The default level. Use this level for the majority of your content, including for your app’s main window.
let UIWindowLevelAlert: UIWindowLevel
The level for an alert view. Windows at this level appear on top of windows at the UIWindowLevelNormal level.
let UIWindowLevelStatusBar: UIWindowLevel
The level for a status window. Windows at this level appear on top of windows at the UIWindowLevelAlert level.
I filled a bug in Apple's Bug Reporter.
My solution was to create a CGFloat with value over 2000 and add it to windowLevel.
Upvotes: 7