3

I need to change the color of status bar in my app.I'm using the code below

- (void)viewDidLoad {
    [super viewDidLoad];
     ....
    [self setNeedsStatusBarAppearanceUpdate];
}

-(UIStatusBarStyle)preferredStatusBarStyle{
    return UIStatusBarStyleLightContent;
}

but this cause my app to crash.

EXC_BAD_ACCESS Error

It is sometimes produce memory warning.

What is the best way to handle this ?

1 Answers1

0

Try Using

if ([self  respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)])
 {
    [self setNeedsStatusBarAppearanceUpdate];
}

if your app supports older version than iOS 7,and you ever need to use something such as setNeedsStatusBarAppearanceUpdate , you can first check if the selector is supported

Shruti
  • 1,849
  • 1
  • 13
  • 21