2

I need to change the color of status bar text in first view controller to white and in the second view controller it should change to black. Tried with View controller-based status bar appearance to NO and called

-(UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}

But it was not changing. Please suggest me.

iphony
  • 119
  • 9
  • try this code in viewdidload method of desired viewcontroller [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; [self setNeedsStatusBarAppearanceUpdate]; working in my case – Muhammad Waqas Bhati Jan 26 '15 at 10:50

2 Answers2

4

Go to your Plist file and add this property with Bool YES.

Then use

-(UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}

Have a look into attached screenshot-

enter image description here

abhishekkharwar
  • 3,529
  • 2
  • 18
  • 31
0

You need to have view controller based status bar appearance set to YES for preferredStatusBarStyle to work. If you're still having issues after that then take a look at this SO question: preferredStatusBarStyle isn't called

Community
  • 1
  • 1
Austen Chongpison
  • 3,966
  • 1
  • 20
  • 17