문제

Now i Am using Xcode 4.2 to develop app.and the app is running on iOS 7 iPhone.My problem related with status bar color.I want the status bar color is same color as of navigation bar color.I am using this code for setting navigation bar image ,here is my code:

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"nav_bar.png"] forBarMetrics:UIBarMetricsDefault];

How we can set the status bar color?now is light gray color>>Many thanks....

도움이 되었습니까?

해결책

In iOS6 you can't change the image or the color of the status bar apart from this 2 styles:

[[UIApplication sharedApplication]setStatusBarStyle:UIStatusBarStyleBlackOpaque];

[[UIApplication sharedApplication]setStatusBarStyle:UIStatusBarStyleBlackTranslucent];

다른 팁

chakra's suggestion to add the line of code:

self.navigationController?.navigationBar.isTranslucent = false

works. Add it to your function in the swift files of your controllers. This allows the status bar to be the same color as the navigation bar. I added this as an answer instead of a comment, because I cannot add comments to other answers as yet. The line of code above this line of code does not work for me though.

This works:

self.navigationController?.navigationBar.barTintColor  = UIColor.untSimeioblue
self.navigationController?.navigationBar.isTranslucent = false
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top