2

I am trying to change the status bar style of one of my viewcontrollers. I have put this

  1. set the view based status bar to YES in the plist

2.

 -(UIStatusBarStyle)preferredStatusBarStyle{ return UIStatusBarStyleLightContent; } 
  1. Added this also

[self setNeedsStatusBarAppearanceUpdate]

It works i.e I can see the font color white but just after some time it changes back to its previous type..

3
  • If you are using storyboards, you should check what values you have set in storyboard for each view controller in status bar. Also, where are you calling that function? Commented Oct 18, 2013 at 10:18
  • possible duplicate of How to change Status Bar text color in iOS 7 Commented Oct 18, 2013 at 10:30
  • 1
    I don't think this is a duplicate, as they mention having tried the technique given in the answer of "How to change status bar text color in iOS 7" Commented Oct 18, 2013 at 19:21

4 Answers 4

6

If you are experiencing status bar changing color itself during runtime

try setting set the UIViewControllerBasedStatusBarAppearance to NO in the plist.

And inside your viewController.. set the appearance call inside

-(void)viewDidLayoutSubviews { if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) { [self setNeedsStatusBarAppearanceUpdate]; } } 
Sign up to request clarification or add additional context in comments.

Comments

2

write following code

-(void)viewWillAppear:(BOOL)Animated{ [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; } 

Comments

0

This is the only thing I could get working for iOS7

- (UIStatusBarStyle)preferredStatusBarStyle { return UIStatusBarStyleLightContent; } 

Comments

0

You can check this code, a little trick – but useful sometimes.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.