ios7 - How to change status bar colours separately for each ViewController? -


i'm developing app using ios 7 , storyboards. have several view controllers. want change status bar color according navigation bar color. each viewcontroller has different color navigation bar. know can change status bar colour adding flag info.plist , code this:

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); } } 

but how change color each viewcontroller?

add method each viewcontroller

- (uistatusbarstyle)preferredstatusbarstyle {   return uistatusbarstyledefault; // or uistatusbarstylelightcontent } 

in viewdidload each view controller:

[self preferredstatusbarstyle]; [self performselector:@selector(setneedsstatusbarappearanceupdate)]; 

also in project properties need set yes option: view controller-based status bar appearance


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -