swift - iOS 9 Navigation Bar Tile Background -


i have problems in xcode. tried navigation bar colored wich works perfect but, statusbar wont change color too. search nothing works me.

i hope possible without code. thanks!

here take on this:

first, ios gives 2 kinds of status bar appearance - light or default. important note system status bar no longer has background color. when api refers uistatusbarstylelightcontent, mean white text on clear background. uistatusbarstyledefault black text on clear background.

to set status bar white throughout app:

uiapplication.sharedapplication().statusbarstyle = .lightcontent 

to set status bar black throughout app:

uiapplication.sharedapplication().statusbarstyle = .default 

second, side note, in info.plist, can use uiviewcontrollerbasedstatusbarappearance noif want set above style @ app level (inside appdelegate). otherwise set property yes , implement following method in each view controller set different styles based on needs:

override func preferredstatusbarstyle() -> uistatusbarstyle {     return uistatusbarstyle.lightcontent } 

third, have custom color on status bar, can add uiview of desired colour below status bar this:

uiview *addstatusbar = [[uiview alloc] init]; addstatusbar.frame = cgrectmake(0, 0, screenwidth, 20); addstatusbar.backgroundcolor = [uicolor graycolor]]; //assign here color  [self.window.rootviewcontroller.view addsubview:addstatusbar]; 

fourth, importantly, uinavigationcontroller alter height of uinavigationbar either 44 points or 64 points based on following points:

  • if uinavigationcontroller detects top of view’s frame visually contiguous uiwindow’s top, draws navigation bar height of 64 points.
  • if view’s top not contiguous uiwindow’s top (even if off 1 point), draws navigation bar in “traditional” way height of 44 points.

Comments