From e5325a0600da5406909b62e427eac2215aec9fa5 Mon Sep 17 00:00:00 2001 From: CheckRan <1026609136@qq.com> Date: Tue, 17 Apr 2018 10:23:03 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20tintColor=20=20titleTe?= =?UTF-8?q?xtAttributes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...tionController+KMNavigationBarTransition.m | 23 +++++++++++-------- ...ViewController+KMNavigationBarTransition.m | 4 ++++ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/KMNavigationBarTransition/UINavigationController+KMNavigationBarTransition.m b/KMNavigationBarTransition/UINavigationController+KMNavigationBarTransition.m index 9743056..da552f1 100755 --- a/KMNavigationBarTransition/UINavigationController+KMNavigationBarTransition.m +++ b/KMNavigationBarTransition/UINavigationController+KMNavigationBarTransition.m @@ -91,9 +91,7 @@ - (UIViewController *)km_popViewControllerAnimated:(BOOL)animated { UIViewController *appearingViewController = self.viewControllers[self.viewControllers.count - 2]; if (appearingViewController.km_transitionNavigationBar) { UINavigationBar *appearingNavigationBar = appearingViewController.km_transitionNavigationBar; - self.navigationBar.barTintColor = appearingNavigationBar.barTintColor; - [self.navigationBar setBackgroundImage:[appearingNavigationBar backgroundImageForBarMetrics:UIBarMetricsDefault] forBarMetrics:UIBarMetricsDefault]; - self.navigationBar.shadowImage = appearingNavigationBar.shadowImage; + [self km_settingMoreProperty:appearingNavigationBar]; } if (animated) { disappearingViewController.navigationController.km_backgroundViewHidden = YES; @@ -109,9 +107,8 @@ - (UIViewController *)km_popViewControllerAnimated:(BOOL)animated { [disappearingViewController km_addTransitionNavigationBarIfNeeded]; if (viewController.km_transitionNavigationBar) { UINavigationBar *appearingNavigationBar = viewController.km_transitionNavigationBar; - self.navigationBar.barTintColor = appearingNavigationBar.barTintColor; - [self.navigationBar setBackgroundImage:[appearingNavigationBar backgroundImageForBarMetrics:UIBarMetricsDefault] forBarMetrics:UIBarMetricsDefault]; - self.navigationBar.shadowImage = appearingNavigationBar.shadowImage; + + [self km_settingMoreProperty:appearingNavigationBar]; } if (animated) { disappearingViewController.navigationController.km_backgroundViewHidden = YES; @@ -128,9 +125,8 @@ - (UIViewController *)km_popViewControllerAnimated:(BOOL)animated { UIViewController *rootViewController = self.viewControllers.firstObject; if (rootViewController.km_transitionNavigationBar) { UINavigationBar *appearingNavigationBar = rootViewController.km_transitionNavigationBar; - self.navigationBar.barTintColor = appearingNavigationBar.barTintColor; - [self.navigationBar setBackgroundImage:[appearingNavigationBar backgroundImageForBarMetrics:UIBarMetricsDefault] forBarMetrics:UIBarMetricsDefault]; - self.navigationBar.shadowImage = appearingNavigationBar.shadowImage; + + [self km_settingMoreProperty:appearingNavigationBar]; } if (animated) { disappearingViewController.navigationController.km_backgroundViewHidden = YES; @@ -149,6 +145,15 @@ - (void)km_setViewControllers:(NSArray *)viewControllers ani return [self km_setViewControllers:viewControllers animated:animated]; } +- (void)km_settingMoreProperty:(UINavigationBar *)appearingNavigationBar{ + self.navigationBar.barTintColor = appearingNavigationBar.barTintColor; + [self.navigationBar setBackgroundImage:[appearingNavigationBar backgroundImageForBarMetrics:UIBarMetricsDefault] forBarMetrics:UIBarMetricsDefault]; + self.navigationBar.shadowImage = appearingNavigationBar.shadowImage; + + self.navigationBar.tintColor = appearingNavigationBar.tintColor; + self.navigationBar.titleTextAttributes = appearingNavigationBar.titleTextAttributes; +} + - (BOOL)km_backgroundViewHidden { return [objc_getAssociatedObject(self, _cmd) boolValue]; } diff --git a/KMNavigationBarTransition/UIViewController+KMNavigationBarTransition.m b/KMNavigationBarTransition/UIViewController+KMNavigationBarTransition.m index 3638125..e14fdcd 100644 --- a/KMNavigationBarTransition/UIViewController+KMNavigationBarTransition.m +++ b/KMNavigationBarTransition/UIViewController+KMNavigationBarTransition.m @@ -135,6 +135,10 @@ - (void)km_addTransitionNavigationBarIfNeeded { bar.barTintColor = self.navigationController.navigationBar.barTintColor; [bar setBackgroundImage:[self.navigationController.navigationBar backgroundImageForBarMetrics:UIBarMetricsDefault] forBarMetrics:UIBarMetricsDefault]; bar.shadowImage = self.navigationController.navigationBar.shadowImage; + + bar.tintColor = self.navigationController.navigationBar.tintColor; + bar.titleTextAttributes = self.navigationController.navigationBar.titleTextAttributes; + [self.km_transitionNavigationBar removeFromSuperview]; self.km_transitionNavigationBar = bar; [self km_resizeTransitionNavigationBarFrame]; From 287e2a76072affaa68b0dd597a5ead7e2325e4a5 Mon Sep 17 00:00:00 2001 From: CheckRan <1026609136@qq.com> Date: Tue, 17 Apr 2018 10:57:51 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BE=A7=E6=BB=91cancel=E5=90=8E=EF=BC=8C?= =?UTF-8?q?=E9=A2=9C=E8=89=B2=E5=8F=98=E4=B8=BA=E4=B8=8A=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=9A=84=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...NavigationController+KMNavigationBarTransition.m | 8 ++++---- .../UIViewController+KMNavigationBarTransition.m | 13 ++++++++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/KMNavigationBarTransition/UINavigationController+KMNavigationBarTransition.m b/KMNavigationBarTransition/UINavigationController+KMNavigationBarTransition.m index da552f1..9ef6338 100755 --- a/KMNavigationBarTransition/UINavigationController+KMNavigationBarTransition.m +++ b/KMNavigationBarTransition/UINavigationController+KMNavigationBarTransition.m @@ -91,7 +91,7 @@ - (UIViewController *)km_popViewControllerAnimated:(BOOL)animated { UIViewController *appearingViewController = self.viewControllers[self.viewControllers.count - 2]; if (appearingViewController.km_transitionNavigationBar) { UINavigationBar *appearingNavigationBar = appearingViewController.km_transitionNavigationBar; - [self km_settingMoreProperty:appearingNavigationBar]; + [self km_settingNavigationBarMoreProperty:appearingNavigationBar]; } if (animated) { disappearingViewController.navigationController.km_backgroundViewHidden = YES; @@ -108,7 +108,7 @@ - (UIViewController *)km_popViewControllerAnimated:(BOOL)animated { if (viewController.km_transitionNavigationBar) { UINavigationBar *appearingNavigationBar = viewController.km_transitionNavigationBar; - [self km_settingMoreProperty:appearingNavigationBar]; + [self km_settingNavigationBarMoreProperty:appearingNavigationBar]; } if (animated) { disappearingViewController.navigationController.km_backgroundViewHidden = YES; @@ -126,7 +126,7 @@ - (UIViewController *)km_popViewControllerAnimated:(BOOL)animated { if (rootViewController.km_transitionNavigationBar) { UINavigationBar *appearingNavigationBar = rootViewController.km_transitionNavigationBar; - [self km_settingMoreProperty:appearingNavigationBar]; + [self km_settingNavigationBarMoreProperty:appearingNavigationBar]; } if (animated) { disappearingViewController.navigationController.km_backgroundViewHidden = YES; @@ -145,7 +145,7 @@ - (void)km_setViewControllers:(NSArray *)viewControllers ani return [self km_setViewControllers:viewControllers animated:animated]; } -- (void)km_settingMoreProperty:(UINavigationBar *)appearingNavigationBar{ +- (void)km_settingNavigationBarMoreProperty:(UINavigationBar *)appearingNavigationBar{ self.navigationBar.barTintColor = appearingNavigationBar.barTintColor; [self.navigationBar setBackgroundImage:[appearingNavigationBar backgroundImageForBarMetrics:UIBarMetricsDefault] forBarMetrics:UIBarMetricsDefault]; self.navigationBar.shadowImage = appearingNavigationBar.shadowImage; diff --git a/KMNavigationBarTransition/UIViewController+KMNavigationBarTransition.m b/KMNavigationBarTransition/UIViewController+KMNavigationBarTransition.m index e14fdcd..491226a 100644 --- a/KMNavigationBarTransition/UIViewController+KMNavigationBarTransition.m +++ b/KMNavigationBarTransition/UIViewController+KMNavigationBarTransition.m @@ -67,13 +67,20 @@ - (void)km_viewWillAppear:(BOOL)animated { } } +- (void)km_settingNavigationBarMoreProperty:(UINavigationBar *)bar{ + self.navigationController.navigationBar.barTintColor = bar.barTintColor; + [self.navigationController.navigationBar setBackgroundImage:[bar backgroundImageForBarMetrics:UIBarMetricsDefault] forBarMetrics:UIBarMetricsDefault]; + [self.navigationController.navigationBar setShadowImage:bar.shadowImage]; + + self.navigationController.navigationBar.tintColor = bar.tintColor; + self.navigationController.navigationBar.titleTextAttributes = bar.titleTextAttributes; +} + - (void)km_viewDidAppear:(BOOL)animated { [self km_restoreScrollViewContentInsetAdjustmentBehaviorIfNeeded]; UIViewController *transitionViewController = self.navigationController.km_transitionContextToViewController; if (self.km_transitionNavigationBar) { - self.navigationController.navigationBar.barTintColor = self.km_transitionNavigationBar.barTintColor; - [self.navigationController.navigationBar setBackgroundImage:[self.km_transitionNavigationBar backgroundImageForBarMetrics:UIBarMetricsDefault] forBarMetrics:UIBarMetricsDefault]; - [self.navigationController.navigationBar setShadowImage:self.km_transitionNavigationBar.shadowImage]; + [self km_settingNavigationBarMoreProperty:self.km_transitionNavigationBar]; if (!transitionViewController || [transitionViewController isEqual:self]) { [self.km_transitionNavigationBar removeFromSuperview]; self.km_transitionNavigationBar = nil; From 980c988866bb478bcf994e9ff7dc5b6ac0e110f5 Mon Sep 17 00:00:00 2001 From: CheckRan <1026609136@qq.com> Date: Tue, 24 Apr 2018 15:59:22 +0800 Subject: [PATCH 3/5] translucent bug --- .../UIViewController+KMNavigationBarTransition.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/KMNavigationBarTransition/UIViewController+KMNavigationBarTransition.m b/KMNavigationBarTransition/UIViewController+KMNavigationBarTransition.m index 491226a..adb888d 100644 --- a/KMNavigationBarTransition/UIViewController+KMNavigationBarTransition.m +++ b/KMNavigationBarTransition/UIViewController+KMNavigationBarTransition.m @@ -72,6 +72,8 @@ - (void)km_settingNavigationBarMoreProperty:(UINavigationBar *)bar{ [self.navigationController.navigationBar setBackgroundImage:[bar backgroundImageForBarMetrics:UIBarMetricsDefault] forBarMetrics:UIBarMetricsDefault]; [self.navigationController.navigationBar setShadowImage:bar.shadowImage]; + self.navigationBar.translucent = appearingNavigationBar.translucent; + self.navigationController.navigationBar.tintColor = bar.tintColor; self.navigationController.navigationBar.titleTextAttributes = bar.titleTextAttributes; } From d3c7c09b4946389575d825d3f542c0b478762448 Mon Sep 17 00:00:00 2001 From: CheckRan <1026609136@qq.com> Date: Tue, 24 Apr 2018 16:09:06 +0800 Subject: [PATCH 4/5] translucent bug fix --- .../UIViewController+KMNavigationBarTransition.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/KMNavigationBarTransition/UIViewController+KMNavigationBarTransition.m b/KMNavigationBarTransition/UIViewController+KMNavigationBarTransition.m index adb888d..f8c0b57 100644 --- a/KMNavigationBarTransition/UIViewController+KMNavigationBarTransition.m +++ b/KMNavigationBarTransition/UIViewController+KMNavigationBarTransition.m @@ -72,7 +72,7 @@ - (void)km_settingNavigationBarMoreProperty:(UINavigationBar *)bar{ [self.navigationController.navigationBar setBackgroundImage:[bar backgroundImageForBarMetrics:UIBarMetricsDefault] forBarMetrics:UIBarMetricsDefault]; [self.navigationController.navigationBar setShadowImage:bar.shadowImage]; - self.navigationBar.translucent = appearingNavigationBar.translucent; + self.navigationController.navigationBar.translucent = bar.translucent; self.navigationController.navigationBar.tintColor = bar.tintColor; self.navigationController.navigationBar.titleTextAttributes = bar.titleTextAttributes; From 28574d33889d422a04448ce93e63ebf0aeede105 Mon Sep 17 00:00:00 2001 From: CheckRan <1026609136@qq.com> Date: Sat, 7 Jul 2018 14:08:11 +0800 Subject: [PATCH 5/5] =?UTF-8?q?1.=20add=20layer=20shadow=20config=202.=20s?= =?UTF-8?q?etting=20navigationBar=20and=20revoke=20navigationBar=20use=20s?= =?UTF-8?q?ame=20function=EF=BC=8Ceasy=20to=20read?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ViewController+KMNavigationBarTransition.m | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/KMNavigationBarTransition/UIViewController+KMNavigationBarTransition.m b/KMNavigationBarTransition/UIViewController+KMNavigationBarTransition.m index f8c0b57..169c111 100644 --- a/KMNavigationBarTransition/UIViewController+KMNavigationBarTransition.m +++ b/KMNavigationBarTransition/UIViewController+KMNavigationBarTransition.m @@ -68,14 +68,27 @@ - (void)km_viewWillAppear:(BOOL)animated { } - (void)km_settingNavigationBarMoreProperty:(UINavigationBar *)bar{ - self.navigationController.navigationBar.barTintColor = bar.barTintColor; - [self.navigationController.navigationBar setBackgroundImage:[bar backgroundImageForBarMetrics:UIBarMetricsDefault] forBarMetrics:UIBarMetricsDefault]; - [self.navigationController.navigationBar setShadowImage:bar.shadowImage]; + //revoke navigationBar + return [self km_settingNavigationBarFrom:bar toBar:self.navigationController.navigationBar]; +} + +- (void)km_settingNavigationBarFrom:(UINavigationBar *)fromBar toBar:(UINavigationBar *)toBar{ + toBar.barStyle = fromBar.barStyle; + toBar.barTintColor = fromBar.barTintColor; + [toBar setBackgroundImage:[fromBar backgroundImageForBarMetrics:UIBarMetricsDefault] forBarMetrics:UIBarMetricsDefault]; + [toBar setShadowImage:fromBar.shadowImage]; - self.navigationController.navigationBar.translucent = bar.translucent; + toBar.translucent = fromBar.translucent; - self.navigationController.navigationBar.tintColor = bar.tintColor; - self.navigationController.navigationBar.titleTextAttributes = bar.titleTextAttributes; + toBar.tintColor = fromBar.tintColor; + toBar.titleTextAttributes = fromBar.titleTextAttributes; + + // layer + toBar.layer.shadowColor = fromBar.layer.shadowColor; + toBar.layer.shadowOffset = fromBar.layer.shadowOffset; + toBar.layer.shadowOpacity = fromBar.layer.shadowOpacity; + toBar.layer.shadowPath = fromBar.layer.shadowPath; + toBar.layer.shadowRadius = fromBar.layer.shadowRadius; } - (void)km_viewDidAppear:(BOOL)animated { @@ -85,7 +98,7 @@ - (void)km_viewDidAppear:(BOOL)animated { [self km_settingNavigationBarMoreProperty:self.km_transitionNavigationBar]; if (!transitionViewController || [transitionViewController isEqual:self]) { [self.km_transitionNavigationBar removeFromSuperview]; - self.km_transitionNavigationBar = nil; + self.km_transitionNavigationBar = nil; } } if ([transitionViewController isEqual:self]) { @@ -137,16 +150,9 @@ - (void)km_addTransitionNavigationBarIfNeeded { [self km_adjustScrollViewContentOffsetIfNeeded]; UINavigationBar *bar = [[UINavigationBar alloc] init]; bar.km_isFakeBar = YES; - bar.barStyle = self.navigationController.navigationBar.barStyle; - if (bar.translucent != self.navigationController.navigationBar.translucent) { - bar.translucent = self.navigationController.navigationBar.translucent; - } - bar.barTintColor = self.navigationController.navigationBar.barTintColor; - [bar setBackgroundImage:[self.navigationController.navigationBar backgroundImageForBarMetrics:UIBarMetricsDefault] forBarMetrics:UIBarMetricsDefault]; - bar.shadowImage = self.navigationController.navigationBar.shadowImage; - bar.tintColor = self.navigationController.navigationBar.tintColor; - bar.titleTextAttributes = self.navigationController.navigationBar.titleTextAttributes; + //setting navigatonbar + [self km_settingNavigationBarFrom:self.navigationController.navigationBar toBar:bar]; [self.km_transitionNavigationBar removeFromSuperview]; self.km_transitionNavigationBar = bar;