Many apps can see the color of the status bar with the navigation bar, and it's really raozui.
I. Change the status bar color (StatusBar)
For example, the navigation bar is red and the status bar is green.
To achieve this effect is very simple, is to add a background view.
The simple implementation process is as follows:
1 //set navigation colors available2 [Self.navigationController.navigationBar setbartintcolor:[uicolor redcolor];3 //Create a false status bar with a height of 204UIView *statusbarview = [[UIView alloc] Initwithframe:cgrectmake (0, - -, Self.view.bounds.size.width, -)];5 //set into green6Statusbarview.backgroundcolor=[Uicolor Greencolor];7 //Add to Navigationbar8[Self.navigationController.navigationBar Addsubview:statusbarview];
Two. Customizing the colors of StatusBar and Navigationbar
Say again. Font and color for the title of the navigation bar
The effect is as follows:
The code is as follows:
1 // Attributes Property 2 Nsdictionary *[email Protected]{nsforegroundcolorattributename:[uicolor whitecolor],nsfontattributename:[ Uifont systemfontofsize:+]}; 3 // Set the font size color of the navigation bar 4 [Self.navigationController.navigationBar settitletextattributes:textattributes];
Three. Hide Navigationbar and StatusBar
The effect is as follows:
The code is as follows:
1 // Hide Navigationbar (nav bar)2// [Self.navigationcontroller Setnavigationbarhidden:yes]; 3 [Self.navigationcontroller Setnavigationbarhidden:yes Animated:yes];
The effect is as follows:
The code is as follows:
1 // Hide status bar rewrite Prefersstatusbarhidden2 - (BOOL) Prefersstatusbarhidden3{ 4 return// Yes hidden 5 }
Four. Status bar font Color white
The code is as follows:
Method One:
1 // Set status bar font white 2 // default Black Uibarstyledefault 3 // White Uibarstyleblack; Uibarstyleblackopaque; Uibarstyleblacktranslucent4 [Self.navigationController.navigationBar setbarstyle: Uibarstyleblack]; 5 // [[UIApplication sharedapplication] setstatusbarstyle:uistatusbarstylelightcontent];
Method Two:
1 // status bar Font white override Preferredstatusbarstyle method 2 - (uistatusbarstyle) preferredstatusbarstyle3{4 // Uistatusbarstylelightcontent White 5 // uistatusbarstyledefault Black 6 return uistatusbarstylelightcontent; 7 }
Five. Set the background picture of the navigation bar
The effect is as follows:
The code is as follows:
1 // set the background picture of the navigation bar 2 // set the transparency effect of Navigationbar 3 [Self.navigationController.navigationBar setbackgroundimage:[uiimage imagenamed:@ " navigation bar background picture "] Forbarmetrics:uibarmetricsdefault];
The above contents refer to:
Application of Uinavigationbar and status bar instances in iOS development and hiding various bar//http://www.111cn.net/sj/ios8/90056.htm
IOS implements a custom navigation bar background as well as a custom color status bar (supports 7.0 and lower versions)//http://www.cnblogs.com/wt616/p/3784717.html
iOS implements custom status bar StatusBar and navigation bar Navigationbar status and color