views:

380

answers:

1

In the iPhone app that I am currently developing, I present several "alert" views that mimic the behaviour of UIAlertView and UIActionSheet. These views require non-standard elements that are not available in UIAlertView or UIActionSheet. Rather than attempt to subclass either, I have created my own classes so that I can easily customize the look and feel of the alerts.

The one problem I am having with this is that I am having trouble fading the iPhone screen when the alert views are presented. I would like to fade out the whole screen (including the status bar) when presenting my custom views in the same way that UIAlertView and UIActionSheet do. I am trying to accomplish this by overlaying a semi-transparent view over the whole screen, but regardless of whether I add the view as a subview of the keyWindow or the topmost view, the status bar never gets shaded.

Does anyone have any suggestions on how to accomplish this? This seems like something that should be simple to do, so I'm probably overlooking something.

+1  A: 

I haven't done this, but if you want to overlay anything over the status bar, I'd say you'll have to create a UIWindow instance and set its windowLevel to UIWindowLevelStatusBar. Or find the status bar window in the view hierarchy and add a semi-opaque subview to it.

Ole Begemann
The statusbar window won't be present in `[[UIApplication sharedApplication] windows]`--it only has a list of `UIWindow`s that the application owns. (other than that, your answer is spot on)
rpetrich
Thanks! I completely overlooked the windowLevel property. Unfortunately, I've also found in the documentation that Apple strongly discourages creating multiple windows in an app, especially for the case of displaying alerts. I wonder if doing this won't bite me later on and result in rejection from the App Store.
glorifiedHacker