Peter Stuart
Peter Stuart

Reputation: 2434

Error when changing navigation status bar text color in objective-c

I am trying to change the text color in the status bar and everything within the navigation.

I am using this code:

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

This code does work, however I receive a caution:

Implicit conversion from enumeration type 'enum UIStatusBar' to different enumeration type 'UIBarStyle' (aka) 'enum UIBarStyle').

Could someone tell me what I am doing wrong?

Peter

Upvotes: 3

Views: 543

Answers (1)

Priyatham51
Priyatham51

Reputation: 1884

For updating status bar color you can do this

[self setNeedsStatusBarAppearanceUpdate]; 

and you should have this defined

-(UIStatusBarStyle)preferredStatusBarStyle{
    return UIStatusBarStyleDefault;
}

for the navigation bar text color

[self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];
[self.navigationItem.title = @"Test"];

Upvotes: 2

Related Questions