Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Status bar background color iOS 7 [duplicate]

iOS 6 look...

enter image description here

Same way i would like to display status bar in iOS 7 like

see this

enter image description here

but My actual output (Overlap)

i have tried following logic

open your info.plist and set "View controller-based status bar appearance" = NO

it's not working in my code,,,

like image 684
SWT Avatar asked Oct 04 '13 08:10

SWT


People also ask

How do I change the color of my status bar on my Iphone?

Go to the Storyboard. Select the View and in the Attributes Inspector change the Background Color to Light Gray. Build and Run the Project. The default style of the status bar is dark content.

How can I change status bar background color?

Step 1: After opening the android studio and creating a new project with an empty activity. Step 2: Navigate to res/values/colors. xml, and add a color that you want to change for the status bar.

How do I change the color of my activity bar?

Just go to res/values/styles.edit the xml file to change the color of action bar.

How do I change the color of my status bar in Swift 4?

Open your info. plist and set UIViewControllerBasedStatusBarAppearance to false . In the first function in AppDelegate. swift , which contains didFinishLaunchingWithOptions , set the color you want.


1 Answers

You have to do 2 things. First is to open your info.plist and set "View controller-based status bar appearance" = NO

And the second is to add this lines to application:didFinishLaunchingWithOptions

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7)
{   
    self.window.clipsToBounds = YES;
    [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackOpaque];     

    UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
    if(orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
    {
        self.window.frame =  CGRectMake(20, 0,self.window.frame.size.width-20,self.window.frame.size.height);
        self.window.bounds = CGRectMake(20, 0, self.window.frame.size.width, self.window.frame.size.height);
    } else
    {
        self.window.frame =  CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height-20);
        self.window.bounds = CGRectMake(0, 20, self.window.frame.size.width, self.window.frame.size.height);
    }
}
like image 153
Stanislav Avatar answered Nov 07 '22 07:11

Stanislav