Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Wrong navigation bar color #51

Closed
aminiz opened this issue Sep 24, 2015 · 6 comments
Closed

Wrong navigation bar color #51

aminiz opened this issue Sep 24, 2015 · 6 comments

Comments

@aminiz
Copy link

aminiz commented Sep 24, 2015

The following line in AppDelegate makes navigationBar background and text color white.
Chameleon.setGlobalThemeUsingPrimaryColor(FlatMint(), withSecondaryColor: FlatBlue(), andContentStyle: UIContentStyle.Contrast)

@bre7
Copy link
Collaborator

bre7 commented Sep 25, 2015

This line is the problem:

[[UINavigationBar appearance] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];

When trying to hide the hairline image, the translucency effect is also being disabled. More info: https://stackoverflow.com/a/32209688/2124535 and https://stackoverflow.com/a/19227158/2124535

Solution (works):

// Use swizzling in UIViewController and execute the following
- (void)swizzledMethod() {
    [self findHairlineImageViewUnder:navigationBar].hidden = YES;
}

- (UIImageView *)findHairlineImageViewUnder:(UIView *)view {
    if ([view isKindOfClass:UIImageView.class] && view.bounds.size.height <= 1.0) {
            return (UIImageView *)view;
    }
    for (UIView *subview in view.subviews) {
        UIImageView *imageView = [self findHairlineImageViewUnder:subview];
        if (imageView) {
            return imageView;
        }
    }
    return nil;
}

bars2

Before/After fix

@aminiz
Copy link
Author

aminiz commented Sep 25, 2015

Okay, that worked for me. But I had to make the change in Chameleon.m.

@bre7
Copy link
Collaborator

bre7 commented Sep 25, 2015

Fix will be pushed soon ;)

@aminiz
Copy link
Author

aminiz commented Sep 25, 2015

Thanks!

@vicc
Copy link
Owner

vicc commented Sep 25, 2015

Thanks @bre7! Could you do a pull request with your fix?

@bre7
Copy link
Collaborator

bre7 commented Sep 25, 2015

Will do

bre7 added a commit to bre7/Chameleon that referenced this issue Sep 26, 2015
bre7 added a commit to bre7/Chameleon that referenced this issue Sep 26, 2015
@bre7 bre7 mentioned this issue Sep 26, 2015
@vicc vicc closed this as completed in #52 Sep 27, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants