Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a transparent status bar like the image shown below?

enter image description here

I need a transparent status bar as shown in the image below.

I tried this,

UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];

if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
    statusBar.backgroundColor = [UIColor clearColor];
}

But this basically gives the same result as UIStatusBarStyleLightContent.

like image 637
iOS Nepal Avatar asked Aug 10 '17 16:08

iOS Nepal


2 Answers

By default, status bar has transparent background, you just need to extend frame of your image, behind status bar.

Here is test snapshot for you. I've set UIImageView with red background color and custom image.

enter image description here

like image 63
Krunal Avatar answered Nov 01 '22 02:11

Krunal


For anyone trying to get the imageView to go up into the "ears" of the "notch," make sure to select the imageView and its superView and set their top constraints to zero. The Interface Builder does not default the view into the notch's ears. It will have a top-layout-constraint (below the Status Bar) as default.

like image 32
Anthony Warner Avatar answered Nov 01 '22 02:11

Anthony Warner