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

修复tintColor问题 #42

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 33 additions & 3 deletions YPNavigationBarTransition/internal/UINavigationBar+YPConfigure.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ of this software and associated documentation files (the "Software"), to deal
@implementation UINavigationBar (YPConfigure)

- (void) yp_adjustWithBarStyle:(UIBarStyle)barStyle tintColor:(UIColor *)tintColor {
if (@available(iOS 13.0, *)) {
self.standardAppearance.largeTitleTextAttributes = @{NSForegroundColorAttributeName: tintColor};
self.standardAppearance.titleTextAttributes = @{NSForegroundColorAttributeName: tintColor};

self.overrideUserInterfaceStyle = barStyle == UIBarStyleBlack ? UIUserInterfaceStyleDark : UIUserInterfaceStyleLight;
}

self.barStyle = barStyle;
self.tintColor = tintColor;
}
Expand All @@ -48,10 +55,24 @@ - (void) yp_applyBarConfiguration:(YPBarConfiguration *)configure {

UIView *barBackgroundView = [self yp_backgroundView];
UIImage* const transpanrentImage = [UIImage yp_transparentImage];

if (@available(iOS 13.0, *)) {
/*
注释下一行,DynamicGradientBar不正常,其他常规页面正常
启用下一行,DynamicGradientBar正常了,其他常规页面不正常
*/
// self.standardAppearance.backgroundEffect = nil;
}

if (configure.transparent) {
barBackgroundView.alpha = 0;
self.translucent = YES;
[self setBackgroundImage:transpanrentImage forBarMetrics:UIBarMetricsDefault];

if (@available(iOS 13.0, *)) {
[self.standardAppearance setBackgroundImage:transpanrentImage];
}else{
[self setBackgroundImage:transpanrentImage forBarMetrics:UIBarMetricsDefault];
}
} else {
barBackgroundView.alpha = 1;
self.translucent = configure.translucent;
Expand All @@ -60,10 +81,19 @@ - (void) yp_applyBarConfiguration:(YPBarConfiguration *)configure {
backgroundImage = [UIImage yp_imageWithColor:configure.backgroundColor];
}

[self setBackgroundImage:backgroundImage forBarMetrics:UIBarMetricsDefault];
if (@available(iOS 13.0, *)) {
[self.standardAppearance setBackgroundImage:backgroundImage];
}else{
[self setBackgroundImage:backgroundImage forBarMetrics:UIBarMetricsDefault];
}
}

self.shadowImage = configure.shadowImage ? nil : transpanrentImage;
if (@available(iOS 13.0, *)) {
self.standardAppearance.shadowImage = configure.shadowImage ? nil : transpanrentImage;
self.standardAppearance.shadowColor = nil;
}else{
self.shadowImage = configure.shadowImage ? nil : transpanrentImage;
}

[self setCurrentBarConfigure:configure];
}
Expand Down