Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bar Button Items in Navigation Bar loose textcolor after modal view did cover them #2

Closed
BtStSoft opened this issue Sep 21, 2014 · 8 comments

Comments

@BtStSoft
Copy link

Bar Button Items in Navigation Bar loose textcolor after modal view did cover them
Steps to reproduce:
Make a single view app project with a storyboard.
Change the appDelegate by adding some imports and the code:

In didFinishLaunchingWithOptions:
{
// Override point for customization after application launch.
[MAThemeKit setupThemeWithPrimaryColor:[MAThemeKit colorWithR:0 G:184 B:156] secondaryColor:[UIColor whiteColor] fontName:@"HelveticaNeue-Light" lightStatusBar:NO];
return YES;
}

Embed the single view in a navigation controller using Editor Embed in...
Add a new viewcontroller
Add a Bar Button Item called test, do not specify an image.
Add the following code to the first viewcontroller for the exit segue:

-(IBAction)closeTest:(UIStoryboardSegue *)segue {
NSLog(@"Pop to first viewcontroller");
}
Drag a modal segue from test to the second view controller
Put a button in the second view controller
Drag from this button to the exit icon in the first viewcontroller

Run the project. Everything receives its correct color: navigationbar, title, button bar
Press test, the modal view covers the screen
Press the button, the exit segue is called and the modal screen disappears.
Now the first view has the correct colors for the navigationbar and the title, but the text in the bar button item is only slightly darker than the navigation bar.

Strangely enough: when using an image instead of text, it works ok.

See attached screen shots

image

image

@mamaral
Copy link
Owner

mamaral commented Sep 21, 2014

I've tried to replicate this programmatically by presenting a modal view controller, but it works fine for me. Perhaps this is a segue/storyboard issue?

https://www.dropbox.com/s/u3obaxwhj1b2bb2/nav%20item.mov?dl=0

@BtStSoft
Copy link
Author

The issue only happens when using a text button bar item, not with system or image bar button items.
It is not storyboard related, tested it by adding a modal view to your demo project and adding a dismiss programmatically. Same effect!

https://www.dropbox.com/s/ycbah06bz8sctj5/MAThemeIssueDemo.mp4?dl=0

@mamaral
Copy link
Owner

mamaral commented Sep 21, 2014

Ahh indeed.. Very weird. At first glance this looks like an OS bug, as my code isn't doing anything after viewDidLoad, so perhaps there's a bug in the appearance proxy methods.

@BtStSoft
Copy link
Author

Just found and fixed it!
The Button Appearance is set to the primary color.
It helps when I add this to the code:

#pragma mark - UI Navigation Bar Button
+(void)customizeNavigationBarButtonColor:(UIColor *)buttonColor {
[[UIButton appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleColor:buttonColor forState:UIControlStateNormal];
}

And in the method setupThemeWithPrimaryColor add this line after customizeNavigationBarColor:
[self customizeNavigationBarButtonColor:secondaryColor];

Text now also gets the textcolor when the button is contained in a UINavigationBar, even after being covered by a modal screen. Yay!

@mamaral
Copy link
Owner

mamaral commented Sep 21, 2014

Very weird, thanks for that, I'll incorporate the fix in a moment.. It does seem to be an OS bug, in that you need to set both the line you added above as well as [[UINavigationBar appearance] setTintColor:buttonColor]; for the intended behavior to show.

@mamaral
Copy link
Owner

mamaral commented Sep 21, 2014

17e0476 Should fix it. Let me know how that works.

@BtStSoft
Copy link
Author

Issue fixed! Thanks.

@mamaral
Copy link
Owner

mamaral commented Sep 21, 2014

No, thank you!

@mamaral mamaral closed this as completed Sep 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants