Eric Smith
Eric Smith

Reputation: 1376

How do I arrange the status bar to always be on top?

I'm sure this is a quick fix or there is some setting but for some reason I can't find an answer anywhere.

The UIImageView I have on the screen always is arranged above the status bar, even if I send it to the back as shown in the image.

enter image description here

How can I always keep the status bar on top? I will be sliding images up off the screen through the top edge so I want them to remain under the bar.

Here is some of my code, where I am generating an image and moving it off the top of the screen:

    UIImage *towerBG = [UIImage imageNamed:@"towerbg.png"];
    UIImageView *towerBGView = [[UIImageView alloc] initWithImage:towerBG];
    towerBGView.frame = CGRectMake(0, 150, towerBGView.frame.size.width, towerBGView.frame.size.height);
    [self.view addSubview:towerBGView];
    [self.view sendSubviewToBack:towerBGView];
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1];
    towerBGView.frame = CGRectMake(0, -300, towerBGView.frame.size.width, towerBGView.frame.size.height);
    [UIView commitAnimations];

Upvotes: 1

Views: 160

Answers (1)

Léo Natan
Léo Natan

Reputation: 57040

The problem isn't that the image is on top of the status bar, it is underneath the status bar, but the status bar is transparent, and the image has a black background. Black on black = black.

In interface builder, in the view controller's properties, uncheck all options under Extended Edges. This will make your view not appear under the status bar.

Upvotes: 1

Related Questions