From 37baa749c283ffede62ef54e271b8afb1dc2929f Mon Sep 17 00:00:00 2001 From: huangboju <529940945@qq.com> Date: Thu, 16 Mar 2017 11:00:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ETNavBarTransparent/ETNavBarTransparent.swift | 4 +- .../project.pbxproj | 15 +- .../UserInterfaceState.xcuserstate | Bin 0 -> 14933 bytes .../xcdebugger/Breakpoints_v2.xcbkptlist | 5 + .../ETNavBarTransparentDemo.xcscheme | 91 ++++++ .../xcschemes/xcschememanagement.plist | 22 ++ .../ETNavBarTransparent.swift | 271 ------------------ .../ProfileViewController.swift | 2 +- 8 files changed, 129 insertions(+), 281 deletions(-) create mode 100644 ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/project.xcworkspace/xcuserdata/bojuhuang.xcuserdatad/UserInterfaceState.xcuserstate create mode 100644 ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/xcuserdata/bojuhuang.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist create mode 100644 ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/xcuserdata/bojuhuang.xcuserdatad/xcschemes/ETNavBarTransparentDemo.xcscheme create mode 100644 ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/xcuserdata/bojuhuang.xcuserdatad/xcschemes/xcschememanagement.plist delete mode 100644 ETNavBarTransparentDemo/ETNavBarTransparentDemo/ETNavBarTransparent/ETNavBarTransparent.swift diff --git a/ETNavBarTransparent/ETNavBarTransparent.swift b/ETNavBarTransparent/ETNavBarTransparent.swift index 424302d..25a592a 100644 --- a/ETNavBarTransparent/ETNavBarTransparent.swift +++ b/ETNavBarTransparent/ETNavBarTransparent.swift @@ -18,7 +18,7 @@ extension UIColor { extension DispatchQueue { private static var _onceTracker = [String]() - + public class func once(token: String, block: () -> Void) { objc_sync_enter(self) defer { objc_sync_exit(self) } @@ -233,7 +233,7 @@ extension UIViewController { navigationController?.setNeedsNavigationBackground(alpha: alpha) } } - + open var navBarTintColor: UIColor { get { guard let tintColor = objc_getAssociatedObject(self, &AssociatedKeys.navBarTintColor) as? UIColor else { diff --git a/ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/project.pbxproj b/ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/project.pbxproj index a53f5d6..f41f87f 100644 --- a/ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/project.pbxproj +++ b/ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/project.pbxproj @@ -13,7 +13,7 @@ 373664FC1E6E9BE000239537 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 373664FA1E6E9BE000239537 /* LaunchScreen.storyboard */; }; 3736650D1E6E9C8E00239537 /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3736650B1E6E9C8E00239537 /* MainViewController.swift */; }; 3736650E1E6E9C8E00239537 /* ProfileViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3736650C1E6E9C8E00239537 /* ProfileViewController.swift */; }; - 378A88981E7063C1008AE1EC /* ETNavBarTransparent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 378A88971E7063C1008AE1EC /* ETNavBarTransparent.swift */; }; + D81840871E7A32890081479E /* ETNavBarTransparent.swift in Sources */ = {isa = PBXBuildFile; fileRef = D81840861E7A32890081479E /* ETNavBarTransparent.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -25,7 +25,7 @@ 373664FD1E6E9BE000239537 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 3736650B1E6E9C8E00239537 /* MainViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = ""; }; 3736650C1E6E9C8E00239537 /* ProfileViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProfileViewController.swift; sourceTree = ""; }; - 378A88971E7063C1008AE1EC /* ETNavBarTransparent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ETNavBarTransparent.swift; sourceTree = ""; }; + D81840861E7A32890081479E /* ETNavBarTransparent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ETNavBarTransparent.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -58,7 +58,7 @@ 373664F01E6E9BE000239537 /* ETNavBarTransparentDemo */ = { isa = PBXGroup; children = ( - 378A88961E7063C1008AE1EC /* ETNavBarTransparent */, + D81840851E7A32890081479E /* ETNavBarTransparent */, 373664F11E6E9BE000239537 /* AppDelegate.swift */, 3736650B1E6E9C8E00239537 /* MainViewController.swift */, 3736650C1E6E9C8E00239537 /* ProfileViewController.swift */, @@ -70,12 +70,13 @@ path = ETNavBarTransparentDemo; sourceTree = ""; }; - 378A88961E7063C1008AE1EC /* ETNavBarTransparent */ = { + D81840851E7A32890081479E /* ETNavBarTransparent */ = { isa = PBXGroup; children = ( - 378A88971E7063C1008AE1EC /* ETNavBarTransparent.swift */, + D81840861E7A32890081479E /* ETNavBarTransparent.swift */, ); - path = ETNavBarTransparent; + name = ETNavBarTransparent; + path = ../../ETNavBarTransparent; sourceTree = ""; }; /* End PBXGroup section */ @@ -152,7 +153,7 @@ buildActionMask = 2147483647; files = ( 3736650D1E6E9C8E00239537 /* MainViewController.swift in Sources */, - 378A88981E7063C1008AE1EC /* ETNavBarTransparent.swift in Sources */, + D81840871E7A32890081479E /* ETNavBarTransparent.swift in Sources */, 3736650E1E6E9C8E00239537 /* ProfileViewController.swift in Sources */, 373664F21E6E9BE000239537 /* AppDelegate.swift in Sources */, ); diff --git a/ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/project.xcworkspace/xcuserdata/bojuhuang.xcuserdatad/UserInterfaceState.xcuserstate b/ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/project.xcworkspace/xcuserdata/bojuhuang.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000000000000000000000000000000000000..b9cd1fe22052e76feb836ad1dffd0aa3d843bb9b GIT binary patch literal 14933 zcmd5@d3;mF_Mf?PyQNERk~Uq^v`LpFZD_jCmCdeT1qw86*{Nxpwt+M$NeUDM<|=N; zA|j%QNXrg_xPT%8qPQS#pePS~F1S3mr??<0KKz}V+q4Z9pMU&5zt0aorO7O3&YU^t zd(NCWG_>1oZckR$I|w5N5yYYZ6v#fu9-Wjj$Lez1oQ_E;&W4%RMvr@PipAB~YJ=vQ z6pyoAj__?8AC=)&6oi720!5-Iq(=snhSHG{4MG{nghrxK=z3I%Za|~a7&I1Dp>b$D zYDO)n71_{CGz-~L8*(5gYDaU>T(l4^LU*7$(Nc65T8X+)H`;_Yqb+DF+J?5H9cUlg zkDfwLqXXy}bPzp@o=2~t*U>xZEINnYM<1b2(P!vO^cDIReTRNPzo1{ye=x=jCO8C# zVJTMNNF0T=I0+}?6r75)aSk4gb8#Ln#3S%^xEPPbqwpA9gKKdeo`@&m8?gm9U@Nv^ zCvL|bcp+Yd7vtOU9r#YX3a`iAcn98%AH)0b0sIU;j9Ws{=kX`_Q~VA7 zH~tm>hA-pa@qd_bCW4VN93x}ojDm?};usC1Wzv{*CWk3xhB3pLGNzIl$J8=)Of%EM zv@$kkCNqn%Gi^*KGoM+&+{7$o7BM$7w=lOeYnc0(waop@L(B%Io7v9nVD>UkGW(bV z%rnek=6U7?<{0xL^AhtB^D%Rt`GonD`HcCT`4{sA^Cj~Y^ELA=^8@n>K?Dt+|Si`d01WtXydvCG)I*?ZZ| z>=t$_yA7{nx3iD1kFtB&$Jl-BLH0;(ilf7Be;b7$2?|AFNQ&eWtIVcZ)=u{n_}ya- zbt#Q@i`(6e!chceDCtH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r14d_L%l1?FsE0+LPM1wV!K$)c&Hqti6&%k^+)~ zl0uU7NtH>~q=iYhCEb~HSJLvNbxAvt9!YvM>G7m}NlzyoOgfzOdeWOor;<)5ok=>E z^g+_cNuMPBmK>d&k~}ookxY{xOx~WnD|t`yW64h@?@#_P`J3d6$-g9DPQH?YQzR+j zDO`#oMVS(llA5AVNlO`&aw6qS%Gs3nQ$9?+F|{q#nL0bwlln>Oh14HXe@eZiTcTT~ zTc=yE+o0R1>(=ek?a@7^dqTHg_q6V)?p578x{q~V>Aul@tGl54L3deqMUVAFAE*!3 z%k*k}iauLEL_bVFLSL*e)sNO!=_lyT`a1n2y+z-qpQ~S@U#?%NU!`BIU!&ik@6vD9 zZ`JS6@6tc1KdgUQ|Bn7W{aO7#^&jca>n|82hG>JqU^JKv*@j$0fnkVYxS`lE!BAtU zGfXl}HOw$r3{8e+L#x4MSZKJDn9)0U*&m9`>nRocC2 z52kHM>q^^{wk7RM+K=gB=~3yL^yGA1dRqFR^vv|^^bzS5>DQ-^POnO@O`nuLHGM|< zjp=u$Kb8JT`Zwu68pDloMy)Z$s5hn?vyHjN0^<=BdncnddV<%lsnq>&$;={+9WB=9Mg*wIXX{)|RYYJ<&fS O{$`K)1^*~(_x}K(*3_2( literal 0 HcmV?d00001 diff --git a/ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/xcuserdata/bojuhuang.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/xcuserdata/bojuhuang.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..fe2b454 --- /dev/null +++ b/ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/xcuserdata/bojuhuang.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,5 @@ + + + diff --git a/ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/xcuserdata/bojuhuang.xcuserdatad/xcschemes/ETNavBarTransparentDemo.xcscheme b/ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/xcuserdata/bojuhuang.xcuserdatad/xcschemes/ETNavBarTransparentDemo.xcscheme new file mode 100644 index 0000000..c380336 --- /dev/null +++ b/ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/xcuserdata/bojuhuang.xcuserdatad/xcschemes/ETNavBarTransparentDemo.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/xcuserdata/bojuhuang.xcuserdatad/xcschemes/xcschememanagement.plist b/ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/xcuserdata/bojuhuang.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..9d37c6e --- /dev/null +++ b/ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/xcuserdata/bojuhuang.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + ETNavBarTransparentDemo.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + 373664ED1E6E9BE000239537 + + primary + + + + + diff --git a/ETNavBarTransparentDemo/ETNavBarTransparentDemo/ETNavBarTransparent/ETNavBarTransparent.swift b/ETNavBarTransparentDemo/ETNavBarTransparentDemo/ETNavBarTransparent/ETNavBarTransparent.swift deleted file mode 100644 index fc900b0..0000000 --- a/ETNavBarTransparentDemo/ETNavBarTransparentDemo/ETNavBarTransparent/ETNavBarTransparent.swift +++ /dev/null @@ -1,271 +0,0 @@ -// -// ETNavBarTransparent.swift -// ETNavBarTransparentDemo -// -// Created by Bing on 2017/3/1. -// Copyright © 2017年 tanyunbing. All rights reserved. -// - -import UIKit - -extension UIColor { - //System default bar tint color - open class func defaultNavBarTintColor() -> UIColor { - return UIColor(red: 0, green: 0.478431, blue: 1, alpha: 1.0) - } - -} - -extension UINavigationController { - - open override func viewDidLoad() { - super.viewDidLoad() - delegate = self - } - - override open var preferredStatusBarStyle: UIStatusBarStyle { - return topViewController?.preferredStatusBarStyle ?? .default - } - - open override class func initialize(){ - - if self == UINavigationController.self { - - let needSwizzleSelectorArr = [["ori":NSSelectorFromString("_updateInteractiveTransition:"),"swi":NSSelectorFromString("et_updateInteractiveTransition:")], - ["ori":#selector(popToViewController(_:animated:)),"swi":#selector(et_popToViewController(_:animated:))], - ["ori":#selector(popToRootViewController(animated:)),"swi":#selector(et_popToRootViewController(animated:))]] - - for needSwizzleSelector in needSwizzleSelectorArr { - let originalSelector = needSwizzleSelector["ori"] - let swizzledSelector = needSwizzleSelector["swi"] - let originalMethod = class_getInstanceMethod(self.classForCoder(), originalSelector) - let swizzledMethod = class_getInstanceMethod(self.classForCoder(), swizzledSelector) - method_exchangeImplementations(originalMethod, swizzledMethod) - } - - } - - } - - - func et_updateInteractiveTransition(_ percentComplete: CGFloat) { - et_updateInteractiveTransition(percentComplete) - if let topVC = self.topViewController { - if let coor = topVC.transitionCoordinator { - //Bg Alpha - let fromAlpha = coor.viewController(forKey: .from)?.navBarBgAlpha - let toAlpha = coor.viewController(forKey: .to)?.navBarBgAlpha - let nowAlpha = fromAlpha! + (toAlpha!-fromAlpha!)*percentComplete - - self.setNeedsNavigationBackground(alpha: nowAlpha) - - //tintColor - let fromColor = coor.viewController(forKey: .from)?.navBarTintColor - let toColor = coor.viewController(forKey: .to)?.navBarTintColor - let nowColor = averageColor(fromColor: fromColor!, toColor: toColor!, percent: percentComplete) - self.navigationBar.tintColor = nowColor - } - } - } - - //Calculate the middle Color with translation percent - private func averageColor(fromColor:UIColor, toColor:UIColor, percent:CGFloat) -> UIColor { - var fromRed :CGFloat = 0.0 - var fromGreen :CGFloat = 0.0 - var fromBlue :CGFloat = 0.0 - var fromAlpha :CGFloat = 0.0 - fromColor.getRed(&fromRed, green: &fromGreen, blue: &fromBlue, alpha: &fromAlpha) - - var toRed :CGFloat = 0.0 - var toGreen :CGFloat = 0.0 - var toBlue :CGFloat = 0.0 - var toAlpha :CGFloat = 0.0 - toColor.getRed(&toRed, green: &toGreen, blue: &toBlue, alpha: &toAlpha) - - let nowRed = fromRed + (toRed-fromRed)*percent - let nowGreen = fromGreen + (toGreen-fromGreen)*percent - let nowBlue = fromBlue + (toBlue-fromBlue)*percent - let nowAlpha = fromAlpha + (toAlpha-fromAlpha)*percent - - return UIColor(red: nowRed, green: nowGreen, blue: nowBlue, alpha: nowAlpha) - } - - - func et_popToViewController(_ viewController: UIViewController, animated: Bool) -> [UIViewController]? { - setNeedsNavigationBackground(alpha: (viewController.navBarBgAlpha)) - navigationBar.tintColor = viewController.navBarTintColor - return et_popToViewController(viewController, animated: animated) - } - - func et_popToRootViewController(animated: Bool) -> [UIViewController]? { - setNeedsNavigationBackground(alpha: (viewControllers.first?.navBarBgAlpha)!) - navigationBar.tintColor = viewControllers.first?.navBarTintColor - return et_popToRootViewController(animated: animated) - } - - - fileprivate func setNeedsNavigationBackground(alpha:CGFloat) { - - - let barBackgroundView = navigationBar.subviews[0] - if let shadowView = barBackgroundView.value(forKey: "_shadowView") as? UIView { - shadowView.alpha = alpha - } - - if navigationBar.isTranslucent { - if #available(iOS 10.0, *){ - if navigationBar.backgroundImage(for: .default) == nil { - if let backgroundEffectView = barBackgroundView.value(forKey: "_backgroundEffectView") as? UIView { - backgroundEffectView.alpha = alpha - return - } - } - - }else{ - if let adaptiveBackdrop = barBackgroundView.value(forKey: "_adaptiveBackdrop") as? UIView { - if let backdropEffectView = adaptiveBackdrop.value(forKey: "_backdropEffectView") as? UIView { - backdropEffectView.alpha = alpha - return - } - } - } - - - } - - barBackgroundView.alpha = alpha - - } - - -} - -extension UINavigationController:UINavigationControllerDelegate,UINavigationBarDelegate { - - public func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) { - if let topVC = navigationController.topViewController { - if let coor = topVC.transitionCoordinator { - if #available(iOS 10.0, *) { - coor.notifyWhenInteractionChanges({ (context) in - self.dealInteractionChanges(context) - }) - } else { - coor.notifyWhenInteractionEnds({ (context) in - self.dealInteractionChanges(context) - }) - - } - } - } - } - - private func dealInteractionChanges(_ context:UIViewControllerTransitionCoordinatorContext) { - if context.isCancelled { - let cancellDuration:TimeInterval = context.transitionDuration * Double( context.percentComplete) - UIView.animate(withDuration: cancellDuration, animations: { - - let nowAlpha = (context.viewController(forKey: .from)?.navBarBgAlpha)! - self.setNeedsNavigationBackground(alpha: nowAlpha) - - self.navigationBar.tintColor = context.viewController(forKey: .from)?.navBarTintColor - }) - }else{ - let finishDuration:TimeInterval = context.transitionDuration * Double(1 - context.percentComplete) - UIView.animate(withDuration: finishDuration, animations: { - let nowAlpha = (context.viewController(forKey: .to)?.navBarBgAlpha)! - self.setNeedsNavigationBackground(alpha: nowAlpha) - - self.navigationBar.tintColor = context.viewController(forKey: .to)?.navBarTintColor - }) - } - } - - - - public func navigationBar(_ navigationBar: UINavigationBar, shouldPop item: UINavigationItem) -> Bool { - if let topVC = topViewController { - if let coor = topVC.transitionCoordinator { - if coor.initiallyInteractive { - return true - } - } - } - - - var popToVC: UIViewController? - if viewControllers.count >= (navigationBar.items?.count)! { - popToVC = viewControllers[viewControllers.count-2] - }else{ - popToVC = viewControllers[viewControllers.count-1] - } - - if popToVC != nil { - _ = self.popToViewController(popToVC!, animated: true) - return true - } - - return false - } - - public func navigationBar(_ navigationBar: UINavigationBar, shouldPush item: UINavigationItem) -> Bool { - setNeedsNavigationBackground(alpha: (topViewController?.navBarBgAlpha)!) - navigationBar.tintColor = topViewController?.navBarTintColor - return true - } - -} - - - - -extension UIViewController { - - fileprivate struct AssociatedKeys { - static var navBarBgAlpha: CGFloat = 1.0 - static var navBarTintColor: UIColor = UIColor.defaultNavBarTintColor() - } - - open var navBarBgAlpha: CGFloat { - get { - let alpha = objc_getAssociatedObject(self, &AssociatedKeys.navBarBgAlpha) as? CGFloat - if alpha == nil { - return 1.0 - }else{ - return alpha! - } - - } - set { - var alpha = newValue - if alpha > 1 { - alpha = 1 - } - if alpha < 0 { - alpha = 0 - } - - objc_setAssociatedObject(self, &AssociatedKeys.navBarBgAlpha, alpha, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) - - //Update UI - navigationController?.setNeedsNavigationBackground(alpha: alpha) - } - } - - open var navBarTintColor: UIColor { - get { - let tintColor = objc_getAssociatedObject(self, &AssociatedKeys.navBarTintColor) as? UIColor - if tintColor == nil { - return UIColor.defaultNavBarTintColor() - }else{ - return tintColor! - } - - } - set { - navigationController?.navigationBar.tintColor = newValue - objc_setAssociatedObject(self, &AssociatedKeys.navBarTintColor, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) - } - } - - -} diff --git a/ETNavBarTransparentDemo/ETNavBarTransparentDemo/ProfileViewController.swift b/ETNavBarTransparentDemo/ETNavBarTransparentDemo/ProfileViewController.swift index 4e417d0..0b99490 100644 --- a/ETNavBarTransparentDemo/ETNavBarTransparentDemo/ProfileViewController.swift +++ b/ETNavBarTransparentDemo/ETNavBarTransparentDemo/ProfileViewController.swift @@ -87,7 +87,7 @@ extension ProfileViewController: UITableViewDelegate { } navBarBgAlpha = navAlpha if navAlpha > 0.8 { - navBarTintColor = UIColor.defaultNavBarTintColor() + navBarTintColor = UIColor.defaultNavBarTintColor statusBarShouldLight = false }else{