Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Change the color of status bar

How can we change the color of the status bar? I know we can change the style by

[application setStatusBarStyle:UIStatusBarStyleBlackOpaque];

Please suggest.

like image 969
Abhinav Avatar asked Dec 16 '10 00:12

Abhinav


People also ask

How can I change the color of my status bar?

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. Step 3: In your MainActivity, add this code in your onCreate method.

How do I change my status bar?

To customize it, first pull down the slider bar from the top of the screen. Next, tap on the three vertical dots in the top right corner. Now click on Status bar. You're in.

How do I change my toolbar color on android?

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


2 Answers

Actually, you can, but it's a hack (and apple def. has another, better way of doing it that we don't have access to):
Set the status bar to black translucent and have a (sub)view with your wanted color as backgroundcolor directly behind it. That way you can get the effect of a different color, even with a gradient.
the frame for that would be CGRectMake(0,0,320,20)

like image 126
Blitz Avatar answered Oct 11 '22 13:10

Blitz


Just for information, for those who don't want to change view frames, setting window background will also work.

I wrote this in AppDelegate.

self.window.backgroundColor = [UIColor colorWithRed:0.78f green:0.13f blue:0.11f alpha:1];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
like image 42
Mohammad Avatar answered Oct 11 '22 12:10

Mohammad