├── .swift-version ├── ETNavBarTransparent.podspec ├── ETNavBarTransparent └── ETNavBarTransparent.swift ├── ETNavBarTransparentDemo ├── ETNavBarTransparentDemo.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcuserdata │ │ │ ├── allinbing.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ │ │ ├── bing.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ │ │ └── bojuhuang.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ ├── allinbing.xcuserdatad │ │ ├── xcdebugger │ │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ │ ├── ETNavBarTransparentDemo.xcscheme │ │ │ └── xcschememanagement.plist │ │ ├── bing.xcuserdatad │ │ ├── xcdebugger │ │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ │ ├── ETNavBarTransparentDemo.xcscheme │ │ │ └── xcschememanagement.plist │ │ └── bojuhuang.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ ├── ETNavBarTransparentDemo.xcscheme │ │ └── xcschememanagement.plist └── ETNavBarTransparentDemo │ ├── AppDelegate.swift │ ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ ├── MainViewController.swift │ └── ProfileViewController.swift ├── LICENSE ├── README.md └── navDemo.gif /.swift-version: -------------------------------------------------------------------------------- 1 | 3.0 2 | -------------------------------------------------------------------------------- /ETNavBarTransparent.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'ETNavBarTransparent' 3 | s.version = '1.1.3' 4 | s.license = 'MIT' 5 | s.summary = 'Change NavigationBar‘s transparency at pop gestrue and other situation' 6 | s.homepage = 'https://github.com/EnderTan/ETNavBarTransparent' 7 | s.author = { 'Ender Tan' => 'endertan@163.com' } 8 | s.social_media_url = 'http://weibo.com/endertan' 9 | s.source = { :git => 'https://github.com/EnderTan/ETNavBarTransparent.git', :tag => '1.1.3' } 10 | s.platform = :ios, '8.0' 11 | s.source_files = 'ETNavBarTransparent','ETNavBarTransparent/**/*' 12 | s.requires_arc = true 13 | s.framework = 'UIKit' 14 | end -------------------------------------------------------------------------------- /ETNavBarTransparent/ETNavBarTransparent.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ETNavBarTransparent.swift 3 | // ETNavBarTransparentDemo 4 | // 5 | // Created by Bing on 2017/3/1. 6 | // Copyright © 2017年 tanyunbing. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | extension UIColor { 12 | // System default bar tint color 13 | open class var defaultNavBarTintColor: UIColor { 14 | return UIColor(red: 0, green: 0.478431, blue: 1, alpha: 1.0) 15 | } 16 | } 17 | 18 | extension DispatchQueue { 19 | 20 | private static var onceTracker = [String]() 21 | 22 | public class func once(token: String, block: () -> Void) { 23 | objc_sync_enter(self) 24 | defer { objc_sync_exit(self) } 25 | 26 | if onceTracker.contains(token) { 27 | return 28 | } 29 | 30 | onceTracker.append(token) 31 | block() 32 | } 33 | } 34 | 35 | extension UINavigationController { 36 | 37 | override open var preferredStatusBarStyle: UIStatusBarStyle { 38 | return topViewController?.preferredStatusBarStyle ?? .default 39 | } 40 | 41 | open override func viewDidLoad() { 42 | UINavigationController.swizzle() 43 | super.viewDidLoad() 44 | } 45 | 46 | private static let onceToken = UUID().uuidString 47 | 48 | class func swizzle() { 49 | guard self == UINavigationController.self else { return } 50 | 51 | DispatchQueue.once(token: onceToken) { 52 | let needSwizzleSelectorArr = [ 53 | NSSelectorFromString("_updateInteractiveTransition:"), 54 | #selector(popViewController(animated:)), 55 | #selector(popToViewController(_:animated:)), 56 | #selector(popToRootViewController(animated:)) 57 | ] 58 | 59 | for selector in needSwizzleSelectorArr { 60 | 61 | let str = ("et_" + selector.description).replacingOccurrences(of: "__", with: "_") 62 | // popToRootViewControllerAnimated: et_popToRootViewControllerAnimated: 63 | 64 | let originalMethod = class_getInstanceMethod(self, selector) 65 | let swizzledMethod = class_getInstanceMethod(self, Selector(str)) 66 | if originalMethod != nil && swizzledMethod != nil { 67 | method_exchangeImplementations(originalMethod!, swizzledMethod!) 68 | } 69 | } 70 | } 71 | } 72 | 73 | @objc func et_updateInteractiveTransition(_ percentComplete: CGFloat) { 74 | guard let topViewController = topViewController, let coordinator = topViewController.transitionCoordinator else { 75 | et_updateInteractiveTransition(percentComplete) 76 | return 77 | } 78 | 79 | if #available(iOS 10.0, *) { 80 | coordinator.notifyWhenInteractionChanges({ (context) in 81 | self.dealInteractionChanges(context) 82 | }) 83 | } else { 84 | coordinator.notifyWhenInteractionEnds({ (context) in 85 | self.dealInteractionChanges(context) 86 | }) 87 | } 88 | 89 | let fromViewController = coordinator.viewController(forKey: .from) 90 | let toViewController = coordinator.viewController(forKey: .to) 91 | 92 | // Bg Alpha 93 | let fromAlpha = fromViewController?.navBarBgAlpha ?? 0 94 | let toAlpha = toViewController?.navBarBgAlpha ?? 0 95 | let newAlpha = fromAlpha + (toAlpha - fromAlpha) * percentComplete 96 | 97 | setNeedsNavigationBackground(alpha: newAlpha) 98 | 99 | // Tint Color 100 | let fromColor = fromViewController?.navBarTintColor ?? .blue 101 | let toColor = toViewController?.navBarTintColor ?? .blue 102 | let newColor = averageColor(fromColor: fromColor, toColor: toColor, percent: percentComplete) 103 | navigationBar.tintColor = newColor 104 | et_updateInteractiveTransition(percentComplete) 105 | } 106 | 107 | // Calculate the middle Color with translation percent 108 | private func averageColor(fromColor: UIColor, toColor: UIColor, percent: CGFloat) -> UIColor { 109 | var fromRed: CGFloat = 0 110 | var fromGreen: CGFloat = 0 111 | var fromBlue: CGFloat = 0 112 | var fromAlpha: CGFloat = 0 113 | fromColor.getRed(&fromRed, green: &fromGreen, blue: &fromBlue, alpha: &fromAlpha) 114 | 115 | var toRed: CGFloat = 0 116 | var toGreen: CGFloat = 0 117 | var toBlue: CGFloat = 0 118 | var toAlpha: CGFloat = 0 119 | toColor.getRed(&toRed, green: &toGreen, blue: &toBlue, alpha: &toAlpha) 120 | 121 | let nowRed = fromRed + (toRed - fromRed) * percent 122 | let nowGreen = fromGreen + (toGreen - fromGreen) * percent 123 | let nowBlue = fromBlue + (toBlue - fromBlue) * percent 124 | let nowAlpha = fromAlpha + (toAlpha - fromAlpha) * percent 125 | 126 | return UIColor(red: nowRed, green: nowGreen, blue: nowBlue, alpha: nowAlpha) 127 | } 128 | 129 | @objc func et_popToViewController(_ viewController: UIViewController, animated: Bool) -> [UIViewController]? { 130 | setNeedsNavigationBackground(alpha: viewController.navBarBgAlpha) 131 | navigationBar.tintColor = viewController.navBarTintColor 132 | return et_popToViewController(viewController, animated: animated) 133 | } 134 | 135 | @objc func et_popViewControllerAnimated(_ animated: Bool) -> UIViewController? { 136 | if #available(iOS 13.0, *) { 137 | if (viewControllers.count > 1 && interactivePopGestureRecognizer?.state != .began){ 138 | let popToVC = viewControllers[viewControllers.count - 2] 139 | setNeedsNavigationBackground(alpha: popToVC.navBarBgAlpha) 140 | navigationBar.tintColor = popToVC.navBarTintColor 141 | } 142 | } 143 | return et_popViewControllerAnimated(animated) 144 | } 145 | 146 | @objc func et_popToRootViewControllerAnimated(_ animated: Bool) -> [UIViewController]? { 147 | setNeedsNavigationBackground(alpha: viewControllers.first?.navBarBgAlpha ?? 0) 148 | navigationBar.tintColor = viewControllers.first?.navBarTintColor 149 | return et_popToRootViewControllerAnimated(animated) 150 | } 151 | 152 | fileprivate func setNeedsNavigationBackground(alpha: CGFloat) { 153 | if let barBackgroundView = navigationBar.subviews.first { 154 | let valueForKey = barBackgroundView.getIvar(forKey:) 155 | 156 | if let shadowView = valueForKey("_shadowView") as? UIView { 157 | shadowView.alpha = alpha 158 | shadowView.isHidden = alpha == 0 159 | } 160 | 161 | if navigationBar.isTranslucent { 162 | if #available(iOS 10.0, *) { 163 | if let backgroundEffectView = valueForKey("_backgroundEffectView") as? UIView, navigationBar.backgroundImage(for: .default) == nil { 164 | backgroundEffectView.alpha = alpha 165 | return 166 | } 167 | 168 | } else { 169 | if let adaptiveBackdrop = valueForKey("_adaptiveBackdrop") as? UIView , let backdropEffectView = adaptiveBackdrop.value(forKey: "_backdropEffectView") as? UIView { 170 | backdropEffectView.alpha = alpha 171 | return 172 | } 173 | } 174 | } 175 | 176 | barBackgroundView.alpha = alpha 177 | } 178 | 179 | } 180 | } 181 | 182 | extension NSObject { 183 | func getIvar(forKey key: String) -> Any? { 184 | guard let _var = class_getInstanceVariable(type(of: self), key) else { 185 | return nil 186 | } 187 | 188 | return object_getIvar(self, _var) 189 | } 190 | } 191 | 192 | extension UINavigationController: UINavigationBarDelegate { 193 | 194 | public func navigationBar(_ navigationBar: UINavigationBar, shouldPop item: UINavigationItem) -> Bool { 195 | if let topVC = topViewController, let coor = topVC.transitionCoordinator, coor.initiallyInteractive { 196 | if #available(iOS 10.0, *) { 197 | coor.notifyWhenInteractionChanges({ (context) in 198 | self.dealInteractionChanges(context) 199 | }) 200 | } else { 201 | coor.notifyWhenInteractionEnds({ (context) in 202 | self.dealInteractionChanges(context) 203 | }) 204 | } 205 | return true 206 | } 207 | 208 | let itemCount = navigationBar.items?.count ?? 0 209 | let n = viewControllers.count >= itemCount ? 2 : 1 210 | let popToVC = viewControllers[viewControllers.count - n] 211 | if #available(iOS 13.0, *) { 212 | setNeedsNavigationBackground(alpha: popToVC.navBarBgAlpha) 213 | navigationBar.tintColor = popToVC.navBarTintColor 214 | } else { 215 | popToViewController(popToVC, animated: true) 216 | } 217 | return true 218 | } 219 | 220 | public func navigationBar(_ navigationBar: UINavigationBar, shouldPush item: UINavigationItem) -> Bool { 221 | setNeedsNavigationBackground(alpha: topViewController?.navBarBgAlpha ?? 0) 222 | navigationBar.tintColor = topViewController?.navBarTintColor 223 | return true 224 | } 225 | 226 | private func dealInteractionChanges(_ context: UIViewControllerTransitionCoordinatorContext) { 227 | let animations: (UITransitionContextViewControllerKey) -> () = { 228 | let nowAlpha = context.viewController(forKey: $0)?.navBarBgAlpha ?? 0 229 | self.setNeedsNavigationBackground(alpha: nowAlpha) 230 | 231 | self.navigationBar.tintColor = context.viewController(forKey: $0)?.navBarTintColor 232 | } 233 | 234 | if context.isCancelled { 235 | let cancelDuration: TimeInterval = context.transitionDuration * Double(context.percentComplete) 236 | UIView.animate(withDuration: cancelDuration) { 237 | animations(.from) 238 | } 239 | } else { 240 | let finishDuration: TimeInterval = context.transitionDuration * Double(1 - context.percentComplete) 241 | UIView.animate(withDuration: finishDuration) { 242 | animations(.to) 243 | } 244 | } 245 | } 246 | } 247 | 248 | extension UIViewController { 249 | 250 | fileprivate struct AssociatedKeys { 251 | static var navBarBgAlpha: CGFloat = 1.0 252 | static var navBarTintColor: UIColor = UIColor.defaultNavBarTintColor 253 | } 254 | 255 | open var navBarBgAlpha: CGFloat { 256 | get { 257 | guard let alpha = objc_getAssociatedObject(self, &AssociatedKeys.navBarBgAlpha) as? CGFloat else { 258 | return 1.0 259 | } 260 | return alpha 261 | 262 | } 263 | set { 264 | let alpha = max(min(newValue, 1), 0) // 必须在 0~1的范围 265 | 266 | objc_setAssociatedObject(self, &AssociatedKeys.navBarBgAlpha, alpha, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) 267 | 268 | // Update UI 269 | navigationController?.setNeedsNavigationBackground(alpha: alpha) 270 | } 271 | } 272 | 273 | open var navBarTintColor: UIColor { 274 | get { 275 | guard let tintColor = objc_getAssociatedObject(self, &AssociatedKeys.navBarTintColor) as? UIColor else { 276 | return UIColor.defaultNavBarTintColor 277 | } 278 | return tintColor 279 | 280 | } 281 | set { 282 | navigationController?.navigationBar.tintColor = newValue 283 | objc_setAssociatedObject(self, &AssociatedKeys.navBarTintColor, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) 284 | } 285 | } 286 | } 287 | -------------------------------------------------------------------------------- /ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 373664F21E6E9BE000239537 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 373664F11E6E9BE000239537 /* AppDelegate.swift */; }; 11 | 373664F71E6E9BE000239537 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 373664F51E6E9BE000239537 /* Main.storyboard */; }; 12 | 373664F91E6E9BE000239537 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 373664F81E6E9BE000239537 /* Assets.xcassets */; }; 13 | 373664FC1E6E9BE000239537 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 373664FA1E6E9BE000239537 /* LaunchScreen.storyboard */; }; 14 | 3736650D1E6E9C8E00239537 /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3736650B1E6E9C8E00239537 /* MainViewController.swift */; }; 15 | 3736650E1E6E9C8E00239537 /* ProfileViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3736650C1E6E9C8E00239537 /* ProfileViewController.swift */; }; 16 | D81840871E7A32890081479E /* ETNavBarTransparent.swift in Sources */ = {isa = PBXBuildFile; fileRef = D81840861E7A32890081479E /* ETNavBarTransparent.swift */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXFileReference section */ 20 | 373664EE1E6E9BE000239537 /* ETNavBarTransparentDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ETNavBarTransparentDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 21 | 373664F11E6E9BE000239537 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 22 | 373664F61E6E9BE000239537 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 23 | 373664F81E6E9BE000239537 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 24 | 373664FB1E6E9BE000239537 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 25 | 373664FD1E6E9BE000239537 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 26 | 3736650B1E6E9C8E00239537 /* MainViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = ""; }; 27 | 3736650C1E6E9C8E00239537 /* ProfileViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProfileViewController.swift; sourceTree = ""; }; 28 | D81840861E7A32890081479E /* ETNavBarTransparent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ETNavBarTransparent.swift; sourceTree = ""; }; 29 | /* End PBXFileReference section */ 30 | 31 | /* Begin PBXFrameworksBuildPhase section */ 32 | 373664EB1E6E9BE000239537 /* Frameworks */ = { 33 | isa = PBXFrameworksBuildPhase; 34 | buildActionMask = 2147483647; 35 | files = ( 36 | ); 37 | runOnlyForDeploymentPostprocessing = 0; 38 | }; 39 | /* End PBXFrameworksBuildPhase section */ 40 | 41 | /* Begin PBXGroup section */ 42 | 373664E51E6E9BE000239537 = { 43 | isa = PBXGroup; 44 | children = ( 45 | 373664F01E6E9BE000239537 /* ETNavBarTransparentDemo */, 46 | 373664EF1E6E9BE000239537 /* Products */, 47 | ); 48 | sourceTree = ""; 49 | }; 50 | 373664EF1E6E9BE000239537 /* Products */ = { 51 | isa = PBXGroup; 52 | children = ( 53 | 373664EE1E6E9BE000239537 /* ETNavBarTransparentDemo.app */, 54 | ); 55 | name = Products; 56 | sourceTree = ""; 57 | }; 58 | 373664F01E6E9BE000239537 /* ETNavBarTransparentDemo */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | D81840851E7A32890081479E /* ETNavBarTransparent */, 62 | 373664F11E6E9BE000239537 /* AppDelegate.swift */, 63 | 3736650B1E6E9C8E00239537 /* MainViewController.swift */, 64 | 3736650C1E6E9C8E00239537 /* ProfileViewController.swift */, 65 | 373664F51E6E9BE000239537 /* Main.storyboard */, 66 | 373664F81E6E9BE000239537 /* Assets.xcassets */, 67 | 373664FA1E6E9BE000239537 /* LaunchScreen.storyboard */, 68 | 373664FD1E6E9BE000239537 /* Info.plist */, 69 | ); 70 | path = ETNavBarTransparentDemo; 71 | sourceTree = ""; 72 | }; 73 | D81840851E7A32890081479E /* ETNavBarTransparent */ = { 74 | isa = PBXGroup; 75 | children = ( 76 | D81840861E7A32890081479E /* ETNavBarTransparent.swift */, 77 | ); 78 | name = ETNavBarTransparent; 79 | path = ../../ETNavBarTransparent; 80 | sourceTree = ""; 81 | }; 82 | /* End PBXGroup section */ 83 | 84 | /* Begin PBXNativeTarget section */ 85 | 373664ED1E6E9BE000239537 /* ETNavBarTransparentDemo */ = { 86 | isa = PBXNativeTarget; 87 | buildConfigurationList = 373665001E6E9BE000239537 /* Build configuration list for PBXNativeTarget "ETNavBarTransparentDemo" */; 88 | buildPhases = ( 89 | 373664EA1E6E9BE000239537 /* Sources */, 90 | 373664EB1E6E9BE000239537 /* Frameworks */, 91 | 373664EC1E6E9BE000239537 /* Resources */, 92 | ); 93 | buildRules = ( 94 | ); 95 | dependencies = ( 96 | ); 97 | name = ETNavBarTransparentDemo; 98 | productName = ETNavBarTransparentDemo; 99 | productReference = 373664EE1E6E9BE000239537 /* ETNavBarTransparentDemo.app */; 100 | productType = "com.apple.product-type.application"; 101 | }; 102 | /* End PBXNativeTarget section */ 103 | 104 | /* Begin PBXProject section */ 105 | 373664E61E6E9BE000239537 /* Project object */ = { 106 | isa = PBXProject; 107 | attributes = { 108 | LastSwiftUpdateCheck = 0820; 109 | LastUpgradeCheck = 0820; 110 | ORGANIZATIONNAME = EnderTan; 111 | TargetAttributes = { 112 | 373664ED1E6E9BE000239537 = { 113 | CreatedOnToolsVersion = 8.2.1; 114 | LastSwiftMigration = 0900; 115 | ProvisioningStyle = Automatic; 116 | }; 117 | }; 118 | }; 119 | buildConfigurationList = 373664E91E6E9BE000239537 /* Build configuration list for PBXProject "ETNavBarTransparentDemo" */; 120 | compatibilityVersion = "Xcode 3.2"; 121 | developmentRegion = English; 122 | hasScannedForEncodings = 0; 123 | knownRegions = ( 124 | English, 125 | en, 126 | Base, 127 | ); 128 | mainGroup = 373664E51E6E9BE000239537; 129 | productRefGroup = 373664EF1E6E9BE000239537 /* Products */; 130 | projectDirPath = ""; 131 | projectRoot = ""; 132 | targets = ( 133 | 373664ED1E6E9BE000239537 /* ETNavBarTransparentDemo */, 134 | ); 135 | }; 136 | /* End PBXProject section */ 137 | 138 | /* Begin PBXResourcesBuildPhase section */ 139 | 373664EC1E6E9BE000239537 /* Resources */ = { 140 | isa = PBXResourcesBuildPhase; 141 | buildActionMask = 2147483647; 142 | files = ( 143 | 373664FC1E6E9BE000239537 /* LaunchScreen.storyboard in Resources */, 144 | 373664F91E6E9BE000239537 /* Assets.xcassets in Resources */, 145 | 373664F71E6E9BE000239537 /* Main.storyboard in Resources */, 146 | ); 147 | runOnlyForDeploymentPostprocessing = 0; 148 | }; 149 | /* End PBXResourcesBuildPhase section */ 150 | 151 | /* Begin PBXSourcesBuildPhase section */ 152 | 373664EA1E6E9BE000239537 /* Sources */ = { 153 | isa = PBXSourcesBuildPhase; 154 | buildActionMask = 2147483647; 155 | files = ( 156 | 3736650D1E6E9C8E00239537 /* MainViewController.swift in Sources */, 157 | D81840871E7A32890081479E /* ETNavBarTransparent.swift in Sources */, 158 | 3736650E1E6E9C8E00239537 /* ProfileViewController.swift in Sources */, 159 | 373664F21E6E9BE000239537 /* AppDelegate.swift in Sources */, 160 | ); 161 | runOnlyForDeploymentPostprocessing = 0; 162 | }; 163 | /* End PBXSourcesBuildPhase section */ 164 | 165 | /* Begin PBXVariantGroup section */ 166 | 373664F51E6E9BE000239537 /* Main.storyboard */ = { 167 | isa = PBXVariantGroup; 168 | children = ( 169 | 373664F61E6E9BE000239537 /* Base */, 170 | ); 171 | name = Main.storyboard; 172 | sourceTree = ""; 173 | }; 174 | 373664FA1E6E9BE000239537 /* LaunchScreen.storyboard */ = { 175 | isa = PBXVariantGroup; 176 | children = ( 177 | 373664FB1E6E9BE000239537 /* Base */, 178 | ); 179 | name = LaunchScreen.storyboard; 180 | sourceTree = ""; 181 | }; 182 | /* End PBXVariantGroup section */ 183 | 184 | /* Begin XCBuildConfiguration section */ 185 | 373664FE1E6E9BE000239537 /* Debug */ = { 186 | isa = XCBuildConfiguration; 187 | buildSettings = { 188 | ALWAYS_SEARCH_USER_PATHS = NO; 189 | CLANG_ANALYZER_NONNULL = YES; 190 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 191 | CLANG_CXX_LIBRARY = "libc++"; 192 | CLANG_ENABLE_MODULES = YES; 193 | CLANG_ENABLE_OBJC_ARC = YES; 194 | CLANG_WARN_BOOL_CONVERSION = YES; 195 | CLANG_WARN_CONSTANT_CONVERSION = YES; 196 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 197 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 198 | CLANG_WARN_EMPTY_BODY = YES; 199 | CLANG_WARN_ENUM_CONVERSION = YES; 200 | CLANG_WARN_INFINITE_RECURSION = YES; 201 | CLANG_WARN_INT_CONVERSION = YES; 202 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 203 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 204 | CLANG_WARN_UNREACHABLE_CODE = YES; 205 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 206 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 207 | COPY_PHASE_STRIP = NO; 208 | DEBUG_INFORMATION_FORMAT = dwarf; 209 | ENABLE_STRICT_OBJC_MSGSEND = YES; 210 | ENABLE_TESTABILITY = YES; 211 | GCC_C_LANGUAGE_STANDARD = gnu99; 212 | GCC_DYNAMIC_NO_PIC = NO; 213 | GCC_NO_COMMON_BLOCKS = YES; 214 | GCC_OPTIMIZATION_LEVEL = 0; 215 | GCC_PREPROCESSOR_DEFINITIONS = ( 216 | "DEBUG=1", 217 | "$(inherited)", 218 | ); 219 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 220 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 221 | GCC_WARN_UNDECLARED_SELECTOR = YES; 222 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 223 | GCC_WARN_UNUSED_FUNCTION = YES; 224 | GCC_WARN_UNUSED_VARIABLE = YES; 225 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 226 | MTL_ENABLE_DEBUG_INFO = YES; 227 | ONLY_ACTIVE_ARCH = YES; 228 | SDKROOT = iphoneos; 229 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 230 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 231 | TARGETED_DEVICE_FAMILY = "1,2"; 232 | }; 233 | name = Debug; 234 | }; 235 | 373664FF1E6E9BE000239537 /* Release */ = { 236 | isa = XCBuildConfiguration; 237 | buildSettings = { 238 | ALWAYS_SEARCH_USER_PATHS = NO; 239 | CLANG_ANALYZER_NONNULL = YES; 240 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 241 | CLANG_CXX_LIBRARY = "libc++"; 242 | CLANG_ENABLE_MODULES = YES; 243 | CLANG_ENABLE_OBJC_ARC = YES; 244 | CLANG_WARN_BOOL_CONVERSION = YES; 245 | CLANG_WARN_CONSTANT_CONVERSION = YES; 246 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 247 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 248 | CLANG_WARN_EMPTY_BODY = YES; 249 | CLANG_WARN_ENUM_CONVERSION = YES; 250 | CLANG_WARN_INFINITE_RECURSION = YES; 251 | CLANG_WARN_INT_CONVERSION = YES; 252 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 253 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 254 | CLANG_WARN_UNREACHABLE_CODE = YES; 255 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 256 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 257 | COPY_PHASE_STRIP = NO; 258 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 259 | ENABLE_NS_ASSERTIONS = NO; 260 | ENABLE_STRICT_OBJC_MSGSEND = YES; 261 | GCC_C_LANGUAGE_STANDARD = gnu99; 262 | GCC_NO_COMMON_BLOCKS = YES; 263 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 264 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 265 | GCC_WARN_UNDECLARED_SELECTOR = YES; 266 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 267 | GCC_WARN_UNUSED_FUNCTION = YES; 268 | GCC_WARN_UNUSED_VARIABLE = YES; 269 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 270 | MTL_ENABLE_DEBUG_INFO = NO; 271 | SDKROOT = iphoneos; 272 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 273 | TARGETED_DEVICE_FAMILY = "1,2"; 274 | VALIDATE_PRODUCT = YES; 275 | }; 276 | name = Release; 277 | }; 278 | 373665011E6E9BE000239537 /* Debug */ = { 279 | isa = XCBuildConfiguration; 280 | buildSettings = { 281 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 282 | DEVELOPMENT_TEAM = ""; 283 | FRAMEWORK_SEARCH_PATHS = ( 284 | "$(inherited)", 285 | "$(PROJECT_DIR)/ETNavBarTransparentDemo", 286 | ); 287 | INFOPLIST_FILE = ETNavBarTransparentDemo/Info.plist; 288 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 289 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 290 | PRODUCT_BUNDLE_IDENTIFIER = com.endertan.ETNavBarTransparentDemo; 291 | PRODUCT_NAME = "$(TARGET_NAME)"; 292 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 293 | SWIFT_VERSION = 4.0; 294 | }; 295 | name = Debug; 296 | }; 297 | 373665021E6E9BE000239537 /* Release */ = { 298 | isa = XCBuildConfiguration; 299 | buildSettings = { 300 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 301 | DEVELOPMENT_TEAM = ""; 302 | FRAMEWORK_SEARCH_PATHS = ( 303 | "$(inherited)", 304 | "$(PROJECT_DIR)/ETNavBarTransparentDemo", 305 | ); 306 | INFOPLIST_FILE = ETNavBarTransparentDemo/Info.plist; 307 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 308 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 309 | PRODUCT_BUNDLE_IDENTIFIER = com.endertan.ETNavBarTransparentDemo; 310 | PRODUCT_NAME = "$(TARGET_NAME)"; 311 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 312 | SWIFT_VERSION = 4.0; 313 | }; 314 | name = Release; 315 | }; 316 | /* End XCBuildConfiguration section */ 317 | 318 | /* Begin XCConfigurationList section */ 319 | 373664E91E6E9BE000239537 /* Build configuration list for PBXProject "ETNavBarTransparentDemo" */ = { 320 | isa = XCConfigurationList; 321 | buildConfigurations = ( 322 | 373664FE1E6E9BE000239537 /* Debug */, 323 | 373664FF1E6E9BE000239537 /* Release */, 324 | ); 325 | defaultConfigurationIsVisible = 0; 326 | defaultConfigurationName = Release; 327 | }; 328 | 373665001E6E9BE000239537 /* Build configuration list for PBXNativeTarget "ETNavBarTransparentDemo" */ = { 329 | isa = XCConfigurationList; 330 | buildConfigurations = ( 331 | 373665011E6E9BE000239537 /* Debug */, 332 | 373665021E6E9BE000239537 /* Release */, 333 | ); 334 | defaultConfigurationIsVisible = 0; 335 | defaultConfigurationName = Release; 336 | }; 337 | /* End XCConfigurationList section */ 338 | }; 339 | rootObject = 373664E61E6E9BE000239537 /* Project object */; 340 | } 341 | -------------------------------------------------------------------------------- /ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/project.xcworkspace/xcuserdata/allinbing.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EnderTan/ETNavBarTransparent/870ac82337880fafa13a1928c35503a959fd64fa/ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/project.xcworkspace/xcuserdata/allinbing.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/project.xcworkspace/xcuserdata/bing.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EnderTan/ETNavBarTransparent/870ac82337880fafa13a1928c35503a959fd64fa/ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/project.xcworkspace/xcuserdata/bing.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/project.xcworkspace/xcuserdata/bojuhuang.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EnderTan/ETNavBarTransparent/870ac82337880fafa13a1928c35503a959fd64fa/ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/project.xcworkspace/xcuserdata/bojuhuang.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/xcuserdata/allinbing.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/xcuserdata/allinbing.xcuserdatad/xcschemes/ETNavBarTransparentDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/xcuserdata/allinbing.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ETNavBarTransparentDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 373664ED1E6E9BE000239537 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/xcuserdata/bing.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/xcuserdata/bing.xcuserdatad/xcschemes/ETNavBarTransparentDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/xcuserdata/bing.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ETNavBarTransparentDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 373664ED1E6E9BE000239537 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/xcuserdata/bojuhuang.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/xcuserdata/bojuhuang.xcuserdatad/xcschemes/ETNavBarTransparentDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /ETNavBarTransparentDemo/ETNavBarTransparentDemo.xcodeproj/xcuserdata/bojuhuang.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ETNavBarTransparentDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 373664ED1E6E9BE000239537 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /ETNavBarTransparentDemo/ETNavBarTransparentDemo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ETNavBarTransparentDemo 4 | // 5 | // Created by Bing on 2017/3/7. 6 | // Copyright © 2017年 EnderTan. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /ETNavBarTransparentDemo/ETNavBarTransparentDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /ETNavBarTransparentDemo/ETNavBarTransparentDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ETNavBarTransparentDemo/ETNavBarTransparentDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /ETNavBarTransparentDemo/ETNavBarTransparentDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 94 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | -------------------------------------------------------------------------------- /ETNavBarTransparentDemo/ETNavBarTransparentDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /ETNavBarTransparentDemo/ETNavBarTransparentDemo/MainViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MainViewController.swift 3 | // ETNavBarTransparentDemo 4 | // 5 | // Created by Bing on 2017/3/1. 6 | // Copyright © 2017年 tanyunbing. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class MainViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | // Testing for Color NavigationBar 17 | // self.navigationController?.navigationBar.barTintColor = .red 18 | 19 | if #available(iOS 11.0, *) { 20 | // Testing for LargeTitlesMode on iOS11 21 | // self.navigationController?.navigationBar.prefersLargeTitles = true 22 | } 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /ETNavBarTransparentDemo/ETNavBarTransparentDemo/ProfileViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ProfileViewController.swift 3 | // ETNavBarTransparentDemo 4 | // 5 | // Created by Bing on 2017/3/1. 6 | // Copyright © 2017年 tanyunbing. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ProfileViewController: UIViewController { 12 | 13 | @IBOutlet weak var tableView: UITableView! 14 | 15 | fileprivate var statusBarShouldLight = true 16 | 17 | 18 | override func viewDidLoad() { 19 | super.viewDidLoad() 20 | 21 | automaticallyAdjustsScrollViewInsets = false 22 | 23 | tableView.dataSource = self 24 | tableView.delegate = self 25 | 26 | self.navBarBgAlpha = 0 27 | self.navBarTintColor = .white 28 | 29 | } 30 | 31 | override var preferredStatusBarStyle: UIStatusBarStyle { 32 | if statusBarShouldLight { 33 | return .lightContent 34 | } else { 35 | return .default 36 | } 37 | } 38 | 39 | 40 | 41 | @IBAction func popWithCodeAction(_ sender: UIButton) { 42 | _ = navigationController?.popViewController(animated: true) 43 | } 44 | 45 | @IBAction func popToRootAction(_ sender: UIButton) { 46 | _ = navigationController?.popToRootViewController(animated: true) 47 | } 48 | 49 | 50 | } 51 | 52 | extension ProfileViewController: UITableViewDataSource { 53 | func numberOfSections(in tableView: UITableView) -> Int { 54 | return 1 55 | } 56 | 57 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 58 | return 50 59 | } 60 | 61 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 62 | let cell = tableView.dequeueReusableCell(withIdentifier: "profileCell", for: indexPath) 63 | cell.textLabel?.text = "第\(indexPath.row)行" 64 | return cell 65 | } 66 | 67 | } 68 | 69 | extension ProfileViewController: UITableViewDelegate { 70 | 71 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 72 | tableView.deselectRow(at: indexPath, animated: true) 73 | } 74 | 75 | 76 | //MARK:UIScrollViewDelegate 77 | func scrollViewDidScroll(_ scrollView: UIScrollView) { 78 | 79 | 80 | print(scrollView) 81 | 82 | let contentOffsetY = scrollView.contentOffset.y 83 | let showNavBarOffsetY = 200 - topLayoutGuide.length 84 | 85 | 86 | //navigationBar alpha 87 | if contentOffsetY > showNavBarOffsetY { 88 | var navAlpha = (contentOffsetY - (showNavBarOffsetY)) / 40.0 89 | if navAlpha > 1 { 90 | navAlpha = 1 91 | } 92 | navBarBgAlpha = navAlpha 93 | if navAlpha > 0.8 { 94 | navBarTintColor = UIColor.defaultNavBarTintColor 95 | statusBarShouldLight = false 96 | 97 | }else{ 98 | navBarTintColor = UIColor.white 99 | statusBarShouldLight = true 100 | } 101 | }else{ 102 | navBarBgAlpha = 0 103 | navBarTintColor = UIColor.white 104 | statusBarShouldLight = true 105 | } 106 | setNeedsStatusBarAppearanceUpdate() 107 | 108 | 109 | 110 | 111 | } 112 | 113 | 114 | 115 | } 116 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 EnderTan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ETNavBarTransparent 2 | Change NavigationBar's transparency at pop gestrue and other situation 3 | 4 | ## Animation 5 | ![image](https://github.com/EnderTan/ETNavBarTransparentDemo/blob/master/navDemo.gif) 6 | 7 | ## Installation 8 | Add the following line to your Podfile: 9 | ```ruby 10 | pod 'ETNavBarTransparent' 11 | ``` 12 | 13 | Then, run the following command: 14 | ```bash 15 | $ pod install 16 | ``` 17 | 18 | Or, simply drag `ETNavBarTransparent.swift` to your project. 19 | 20 | ## Usage 21 | 22 | Change NavigationBar's transparency and tintColor where you want: 23 | 24 | ```swift 25 | // Example: 26 | // Change in viewDidLoad 27 | override func viewDidLoad() { 28 | super.viewDidLoad() 29 | 30 | self.navBarBgAlpha = 0 31 | self.navBarTintColor = .white 32 | } 33 | 34 | // Change in scrollView scroll 35 | func scrollViewDidScroll(_ scrollView: UIScrollView) { 36 | 37 | if scrollView.contentOffset.y > 100 { 38 | navBarBgAlpha = 1 39 | navBarTintColor = UIColor.defaultNavBarTintColor() 40 | } else { 41 | navBarBgAlpha = 0 42 | navBarTintColor = .white 43 | } 44 | 45 | } 46 | ``` 47 | 48 | ## Related articles 49 | [导航栏的平滑显示和隐藏 - 个人页的自我修养(1)](http://www.jianshu.com/p/454b06590cf1) 50 | 51 | ## License 52 | MIT license. See LICENSE for details. 53 | 54 | ## Contact 55 | Follow and contact me on Weibo [@日光镇](http://weibo.com/endertan) or [My Blog](http://www.jianshu.com/u/a958e552973b) 56 | -------------------------------------------------------------------------------- /navDemo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EnderTan/ETNavBarTransparent/870ac82337880fafa13a1928c35503a959fd64fa/navDemo.gif --------------------------------------------------------------------------------