XCode Warrier
XCode Warrier

Reputation: 775

iOS8 change status bar color without using UINavigationBar

I'd like to change the status bar color without having to show the UINavigationBar.

setBarTintColor works fine if 
[self.navigationController setNavigationBarHidden:NO animated:NO];

however I'm using a custom control that means I have to set

[self.navigationController setNavigationBarHidden:YES animated:NO];

which then means the status bar color is white.

How can I change the status bar color without showing the UINavigationBar?

Upvotes: 0

Views: 1183

Answers (1)

iMokhles
iMokhles

Reputation: 219

if i understand your question well Here is how to change the UIStatusBarStyle on each UIViewController

so u will need to add those lines in your app-info.plist

1-

<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleBlackTranslucent</string>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>

and inside your viewController -(void)viewDidLoad; call the following

2-

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

then declare this selector

3-

- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}

4- here is the list of UIStatusBarStyle

typedef NS_ENUM(NSInteger, UIStatusBarStyle) {
    UIStatusBarStyleDefault                                     = 0, // Dark content, for use on light backgrounds
    UIStatusBarStyleLightContent     NS_ENUM_AVAILABLE_IOS(7_0) = 1, // Light content, for use on dark backgrounds

    UIStatusBarStyleBlackTranslucent NS_ENUM_DEPRECATED_IOS(2_0, 7_0, "Use UIStatusBarStyleLightContent") = 1,
    UIStatusBarStyleBlackOpaque      NS_ENUM_DEPRECATED_IOS(2_0, 7_0, "Use UIStatusBarStyleLightContent") = 2,
};

if u was talking about changing the status bar background color i think u have to see the answers here https://stackoverflow.com/a/21044718/1447546

Upvotes: 1

Related Questions