Doug Smith
Doug Smith

Reputation: 29316

Why can I not make my new UIWindow appear over top of the status bar?

I'm simply trying to place my UIWindow above the status bar temporarily for alert purposes.

The code is quite simple:

    let newwindow = UIWindow(frame: UIScreen.mainScreen().bounds)
    newwindow.hidden = false
    newwindow.backgroundColor = UIColor.greenColor()
    newwindow.windowLevel = UIWindowLevelStatusBar + 1.0
    newwindow.makeKeyAndVisible()
    newwindow.hidden = false

However when I put that in viewDidAppear of my root view controller, I never see this window.

What am I doing wrong?

Upvotes: 0

Views: 538

Answers (1)

Andrea
Andrea

Reputation: 26385

You must retain newwindow somehow, like try to use a strong property. The rest of the code seems ok except for the fact that you call two times hidden

Upvotes: 5

Related Questions