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 ?

  • similar to this question refer this. http://stackoverflow.com/questions/17678881/how-to-change-status-bar-text-color-in-ios-7 – Meenakshi Borade Mar 16 '15 at 07:00
  • I do not want the way to do this,I did it .However,My app crash and I want to solve this problem. – Maram F Balatia Mar 16 '15 at 07:39
  • Dear Matthias Bauch, this question is not related to the unrecognised selector question. Can you please remove the duplicate mark? – Slabko Aug 26 '15 at 14:04

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,809
  • 1
  • 11
  • 20