Praxis
Praxis

Reputation: 125

Changing iOS status bar color or navigation bar color after presenting a view controller?

So I'm using a third party api, specifically, this one: https://github.com/twitchtv/twitch-ios-plugin-bin

What this API does is basically let me make this call:

[[TwitchKit sharedPlugin] presentStreamForChannelNamed:channel.user mode:TKStreamPresentationModeRemainInApp];

where channel.user is a NSString with a Twitch channel name, and a new view pops over my current one with the video stream I am requesting.

I don't see any way to change Twitch's source, so I'm stuck with it how it is.

However, my app uses a dark color scheme, and Twitch's popover has what looks like a navigation bar at the top, but it's white (default Apple color). Since my color scheme is dark, my status bar is white. So when the Twitch overlay pops up, it makes the status bar unreasonable.

There's two simple solutions to this:

Unfortunately, I can't seem to get either of these to work. I tried this right after the presentStreamForChannel call:

[self.presentedViewController.navigationController.navigationBar setBackgroundColor:[UIColor purpleColor]];

but no dice.

I also tried:

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];

with little success.

How can I either make the status bar black when this transition happens, or make the new controller's bar dark?

Upvotes: 0

Views: 2614

Answers (2)

Ashish P.
Ashish P.

Reputation: 858

I have tried demo following solution is working for me.

Go to your info.plist, add property "View controller-based status bar appearance" and set it "NO".

Add following code to your app delegate.

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];

This will make status bar to black through out the app.

Upvotes: 2

Gopinathan
Gopinathan

Reputation: 181

You have to set bartintcolor for the navigationbar, If you want black status bar, set background color of the window to black and set status bar style to blacktranslucent.

[self.presentedViewController.navigationController.navigationBar setBarTintColor:[UIColor purpleColor]];

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];

[[[UIApplication sharedApplication] window] setBackgroundColor:[UIColor blackColor]];

Hope it will work.

Upvotes: 0

Related Questions