-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Code for contrasting status bar style breaks status bar style on navigation controllers, even if not using contrasting status bar style. #95
Comments
That seems to make sense. Thanks for this. I'll try to update it asap. |
I do not usually leave +1s as I know nobody really likes them, but I spent literally hours trying to change status bar color, using different approaches and their combinations until I found out this was the issue. I use chameleon mainly for flat colors and some utils, and it is definitely great piece of work, but I did not even know that it adds some code to UINavigationController (my bad not reading all the docu, but I think I am not the only one) and so did not even think to look here. So yeah this time I would like to +1 this as it is not trivial to find out where the problem actually is. |
@aocenas I find +1's super helpful! They help prioritize issues. With that said, sorry for the trouble. 😞 I'll definitely update this over the weekend, along with a few other things. |
• Fixed issue where Chameleon would override the preferred statusBarStyle even when not being asked to (bad Chameleon!) • Added ability to retrieve the hexString value for any color. Note: I needed this recently, so I figured some of you might find it useful as well!!! (i.e. [coolNewColor hexStringValue]; • Added some new methods for generating random colors. • Added an Objective-c demo project.
@ViccAlexander still does not seem to be fixed. This is the code I am using for testing: func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
window = UIWindow(frame: UIScreen.mainScreen().bounds)
let ctrl = UIViewController()
let navCtrl = UINavigationController(rootViewController: ctrl)
navCtrl.navigationBar.barStyle = .Black
navCtrl.navigationBar.barTintColor = UIColor.grayColor()
navCtrl.navigationBar.translucent = false
window!.rootViewController = navCtrl
window!.makeKeyAndVisible()
return true
} Using navigationBar.barStyle seems like the correct way to do this (http://stackoverflow.com/a/19513714). This code still generates white status bar without chamelon, but black status bar with chameleon 2.1.0 installed. |
@aocenas Had the same issue with chameleon 2.1.0 as well. After debugging for a while, I found that you also have to set the navigation controller status bar style in chameleon. In my case, in Obj-C this worked for me:
|
Based on this StackOverflow answer, we set
navigationBar.barStyle
on our UINavigationController to control the status bar style. When we added Chameleon, we started getting incorrect status bar coloring even though we never used Chameleon to set a contrasting status bar style anywhere in our app.I think that https://github.com/ViccAlexander/Chameleon/blob/master/Pod/Classes/Objective-C/UIViewController%2BChameleon.m#L125 should store the return value from the original method that was swizzled away and return it at https://github.com/ViccAlexander/Chameleon/blob/master/Pod/Classes/Objective-C/UIViewController%2BChameleon.m#L140 instead of always returning
UIStatusBarStyleDefault
.The text was updated successfully, but these errors were encountered: