├── .gitignore ├── .swift-version ├── .travis.yml ├── LICENSE ├── NavigationBarHelper.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── NavigationBarHelper ├── Info.plist ├── NavigationBarBackgroundHelper.h ├── NavigationBarBackgroundView.swift ├── NavigationBarHelper+AttrRestoration.swift ├── NavigationBarHelper.swift ├── UINavigationBar+Swizzle.swift ├── UIViewController+Swizzle.swift └── Utilities.swift ├── NavigationBarHelperDemo ├── AccountViewController.swift ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── avatar.imageset │ │ ├── Contents.json │ │ └── d443839ccaa5d102b747709c8864ad4c.jpeg │ ├── bar_background.imageset │ │ ├── Contents.json │ │ └── DX-20180309@2x.png │ ├── star_sky.imageset │ │ ├── Contents.json │ │ └── DX-20180308@2x.png │ └── timeline.imageset │ │ ├── Contents.json │ │ └── timeline.jpg ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── HideNavigationBarViewController.swift ├── HomeViewController.swift ├── Info.plist ├── ListViewController.swift ├── SetViewController.swift └── TimelineViewController.swift ├── Package.swift ├── PopInterrupter ├── UINavigationController+Swizzle.swift └── UIViewController+PopInterrupter.swift ├── README.md └── screenshot.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | Build/ 7 | DerivedData 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata 19 | 20 | ## Other 21 | *.xccheckout 22 | *.moved-aside 23 | *.xcuserstate 24 | *.xcscmblueprint 25 | *.xcscheme 26 | *.DS_Store 27 | 28 | ## Obj-C/Swift specific 29 | *.hmap 30 | *.ipa 31 | 32 | # CocoaPods 33 | # 34 | # We recommend against adding the Pods directory to your .gitignore. However 35 | # you should judge for yourself, the pros and cons are mentioned at: 36 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 37 | # 38 | # Pods/ 39 | 40 | # Carthage 41 | # 42 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 43 | # Carthage/Checkouts 44 | 45 | Carthage/Build 46 | 47 | ### SwiftPackageManager ### 48 | Packages 49 | .build/ 50 | xcuserdata 51 | DerivedData/ 52 | *.xcodeproj 53 | 54 | # fastlane 55 | # 56 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 57 | # screenshots whenever they are needed. 58 | # For more information about the recommended setup visit: 59 | # https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md 60 | 61 | fastlane/report.xml 62 | fastlane/screenshots -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 5.0 -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | osx_image: xcode10.1 3 | script: 4 | - set -o pipefail 5 | - xcodebuild -version 6 | - xcodebuild -showsdks 7 | - xcodebuild -project "NavigationBarHelper.xcodeproj" -scheme "NavigationBarHelper" -configuration Debug ONLY_ACTIVE_ARCH=NO build 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | copyright (c) 2016 Jerry Wong jerrywong0523@icloud.com 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /NavigationBarHelper.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | C403446320525890002BF6AC /* SetViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C403446220525890002BF6AC /* SetViewController.swift */; }; 11 | C424D7F52060E7C6006B9697 /* UIViewController+PopInterrupter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C424D7F32060E7C6006B9697 /* UIViewController+PopInterrupter.swift */; }; 12 | C424D7F62060E7C6006B9697 /* UINavigationController+Swizzle.swift in Sources */ = {isa = PBXBuildFile; fileRef = C424D7F42060E7C6006B9697 /* UINavigationController+Swizzle.swift */; }; 13 | C425CC7021D5EFB50062F919 /* HideNavigationBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C425CC6F21D5EFB50062F919 /* HideNavigationBarViewController.swift */; }; 14 | C42C1D6D2046CB44004B33D2 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C42C1D6C2046CB44004B33D2 /* AppDelegate.swift */; }; 15 | C42C1D6F2046CB44004B33D2 /* HomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C42C1D6E2046CB44004B33D2 /* HomeViewController.swift */; }; 16 | C42C1D722046CB44004B33D2 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C42C1D702046CB44004B33D2 /* Main.storyboard */; }; 17 | C42C1D742046CB44004B33D2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C42C1D732046CB44004B33D2 /* Assets.xcassets */; }; 18 | C42C1D772046CB44004B33D2 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C42C1D752046CB44004B33D2 /* LaunchScreen.storyboard */; }; 19 | C454316E21391700002BF607 /* UINavigationBar+Swizzle.swift in Sources */ = {isa = PBXBuildFile; fileRef = C454316D21391700002BF607 /* UINavigationBar+Swizzle.swift */; }; 20 | C4543170213917EF002BF607 /* Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = C454316F213917EF002BF607 /* Utilities.swift */; }; 21 | C455E72B2057E83400A3211D /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = C455E7292057E83400A3211D /* README.md */; }; 22 | C455E72C2057E83400A3211D /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = C455E72A2057E83400A3211D /* LICENSE */; }; 23 | C455E7362057EE2E00A3211D /* NavigationBarBackgroundHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = C455E7342057EE2E00A3211D /* NavigationBarBackgroundHelper.h */; settings = {ATTRIBUTES = (Public, ); }; }; 24 | C455E7392057EE2E00A3211D /* NavigationBarHelper.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C455E7322057EE2E00A3211D /* NavigationBarHelper.framework */; }; 25 | C455E73A2057EE2E00A3211D /* NavigationBarHelper.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C455E7322057EE2E00A3211D /* NavigationBarHelper.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 26 | C455E7432057EE9800A3211D /* NavigationBarHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = C455E7402057EE9800A3211D /* NavigationBarHelper.swift */; }; 27 | C455E7442057EE9800A3211D /* NavigationBarBackgroundView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C455E7412057EE9800A3211D /* NavigationBarBackgroundView.swift */; }; 28 | C455E7462058CE1200A3211D /* NavigationBarHelper+AttrRestoration.swift in Sources */ = {isa = PBXBuildFile; fileRef = C455E7452058CE1200A3211D /* NavigationBarHelper+AttrRestoration.swift */; }; 29 | C455E7482058CEAB00A3211D /* UIViewController+Swizzle.swift in Sources */ = {isa = PBXBuildFile; fileRef = C455E7472058CEAB00A3211D /* UIViewController+Swizzle.swift */; }; 30 | C47A327F2051781F00C46FD5 /* ListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C47A327E2051781F00C46FD5 /* ListViewController.swift */; }; 31 | C47A328120517B3600C46FD5 /* AccountViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C47A328020517B3600C46FD5 /* AccountViewController.swift */; }; 32 | C4A681D420BCF9BA00F3EDD7 /* TimelineViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4A681D320BCF9BA00F3EDD7 /* TimelineViewController.swift */; }; 33 | /* End PBXBuildFile section */ 34 | 35 | /* Begin PBXContainerItemProxy section */ 36 | C455E7372057EE2E00A3211D /* PBXContainerItemProxy */ = { 37 | isa = PBXContainerItemProxy; 38 | containerPortal = C42C1D612046CB44004B33D2 /* Project object */; 39 | proxyType = 1; 40 | remoteGlobalIDString = C455E7312057EE2E00A3211D; 41 | remoteInfo = NavigationBarBackgroundHelper; 42 | }; 43 | /* End PBXContainerItemProxy section */ 44 | 45 | /* Begin PBXCopyFilesBuildPhase section */ 46 | C455E73E2057EE2E00A3211D /* Embed Frameworks */ = { 47 | isa = PBXCopyFilesBuildPhase; 48 | buildActionMask = 2147483647; 49 | dstPath = ""; 50 | dstSubfolderSpec = 10; 51 | files = ( 52 | C455E73A2057EE2E00A3211D /* NavigationBarHelper.framework in Embed Frameworks */, 53 | ); 54 | name = "Embed Frameworks"; 55 | runOnlyForDeploymentPostprocessing = 0; 56 | }; 57 | /* End PBXCopyFilesBuildPhase section */ 58 | 59 | /* Begin PBXFileReference section */ 60 | C403446220525890002BF6AC /* SetViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetViewController.swift; sourceTree = ""; }; 61 | C424D7F32060E7C6006B9697 /* UIViewController+PopInterrupter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIViewController+PopInterrupter.swift"; sourceTree = ""; }; 62 | C424D7F42060E7C6006B9697 /* UINavigationController+Swizzle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UINavigationController+Swizzle.swift"; sourceTree = ""; }; 63 | C425CC6F21D5EFB50062F919 /* HideNavigationBarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HideNavigationBarViewController.swift; sourceTree = ""; }; 64 | C4275D8822F40ECA00F6DF3C /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = ""; }; 65 | C42C1D692046CB44004B33D2 /* NavigationBarHelperDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NavigationBarHelperDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 66 | C42C1D6C2046CB44004B33D2 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 67 | C42C1D6E2046CB44004B33D2 /* HomeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeViewController.swift; sourceTree = ""; }; 68 | C42C1D712046CB44004B33D2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 69 | C42C1D732046CB44004B33D2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 70 | C42C1D762046CB44004B33D2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 71 | C42C1D782046CB44004B33D2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 72 | C454316D21391700002BF607 /* UINavigationBar+Swizzle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UINavigationBar+Swizzle.swift"; sourceTree = ""; }; 73 | C454316F213917EF002BF607 /* Utilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utilities.swift; sourceTree = ""; }; 74 | C455E7292057E83400A3211D /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; 75 | C455E72A2057E83400A3211D /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = ""; }; 76 | C455E7322057EE2E00A3211D /* NavigationBarHelper.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = NavigationBarHelper.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 77 | C455E7342057EE2E00A3211D /* NavigationBarBackgroundHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NavigationBarBackgroundHelper.h; sourceTree = ""; }; 78 | C455E7352057EE2E00A3211D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 79 | C455E7402057EE9800A3211D /* NavigationBarHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationBarHelper.swift; sourceTree = ""; }; 80 | C455E7412057EE9800A3211D /* NavigationBarBackgroundView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationBarBackgroundView.swift; sourceTree = ""; }; 81 | C455E7452058CE1200A3211D /* NavigationBarHelper+AttrRestoration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NavigationBarHelper+AttrRestoration.swift"; sourceTree = ""; }; 82 | C455E7472058CEAB00A3211D /* UIViewController+Swizzle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+Swizzle.swift"; sourceTree = ""; }; 83 | C47A327E2051781F00C46FD5 /* ListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListViewController.swift; sourceTree = ""; }; 84 | C47A328020517B3600C46FD5 /* AccountViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountViewController.swift; sourceTree = ""; }; 85 | C4A681D320BCF9BA00F3EDD7 /* TimelineViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineViewController.swift; sourceTree = ""; }; 86 | /* End PBXFileReference section */ 87 | 88 | /* Begin PBXFrameworksBuildPhase section */ 89 | C42C1D662046CB44004B33D2 /* Frameworks */ = { 90 | isa = PBXFrameworksBuildPhase; 91 | buildActionMask = 2147483647; 92 | files = ( 93 | C455E7392057EE2E00A3211D /* NavigationBarHelper.framework in Frameworks */, 94 | ); 95 | runOnlyForDeploymentPostprocessing = 0; 96 | }; 97 | C455E72E2057EE2E00A3211D /* Frameworks */ = { 98 | isa = PBXFrameworksBuildPhase; 99 | buildActionMask = 2147483647; 100 | files = ( 101 | ); 102 | runOnlyForDeploymentPostprocessing = 0; 103 | }; 104 | /* End PBXFrameworksBuildPhase section */ 105 | 106 | /* Begin PBXGroup section */ 107 | C424D7F22060E7C6006B9697 /* PopInterrupter */ = { 108 | isa = PBXGroup; 109 | children = ( 110 | C424D7F32060E7C6006B9697 /* UIViewController+PopInterrupter.swift */, 111 | C424D7F42060E7C6006B9697 /* UINavigationController+Swizzle.swift */, 112 | ); 113 | path = PopInterrupter; 114 | sourceTree = ""; 115 | }; 116 | C42C1D602046CB44004B33D2 = { 117 | isa = PBXGroup; 118 | children = ( 119 | C4275D8822F40ECA00F6DF3C /* Package.swift */, 120 | C455E72A2057E83400A3211D /* LICENSE */, 121 | C455E7292057E83400A3211D /* README.md */, 122 | C424D7F22060E7C6006B9697 /* PopInterrupter */, 123 | C455E7332057EE2E00A3211D /* NavigationBarHelper */, 124 | C42C1D6B2046CB44004B33D2 /* NavigationBarHelperDemo */, 125 | C42C1D6A2046CB44004B33D2 /* Products */, 126 | ); 127 | sourceTree = ""; 128 | }; 129 | C42C1D6A2046CB44004B33D2 /* Products */ = { 130 | isa = PBXGroup; 131 | children = ( 132 | C42C1D692046CB44004B33D2 /* NavigationBarHelperDemo.app */, 133 | C455E7322057EE2E00A3211D /* NavigationBarHelper.framework */, 134 | ); 135 | name = Products; 136 | sourceTree = ""; 137 | }; 138 | C42C1D6B2046CB44004B33D2 /* NavigationBarHelperDemo */ = { 139 | isa = PBXGroup; 140 | children = ( 141 | C42C1D6C2046CB44004B33D2 /* AppDelegate.swift */, 142 | C42C1D6E2046CB44004B33D2 /* HomeViewController.swift */, 143 | C47A327E2051781F00C46FD5 /* ListViewController.swift */, 144 | C47A328020517B3600C46FD5 /* AccountViewController.swift */, 145 | C4A681D320BCF9BA00F3EDD7 /* TimelineViewController.swift */, 146 | C425CC6F21D5EFB50062F919 /* HideNavigationBarViewController.swift */, 147 | C403446220525890002BF6AC /* SetViewController.swift */, 148 | C42C1D702046CB44004B33D2 /* Main.storyboard */, 149 | C42C1D732046CB44004B33D2 /* Assets.xcassets */, 150 | C42C1D752046CB44004B33D2 /* LaunchScreen.storyboard */, 151 | C42C1D782046CB44004B33D2 /* Info.plist */, 152 | ); 153 | path = NavigationBarHelperDemo; 154 | sourceTree = ""; 155 | }; 156 | C455E7332057EE2E00A3211D /* NavigationBarHelper */ = { 157 | isa = PBXGroup; 158 | children = ( 159 | C455E7402057EE9800A3211D /* NavigationBarHelper.swift */, 160 | C455E7412057EE9800A3211D /* NavigationBarBackgroundView.swift */, 161 | C455E7452058CE1200A3211D /* NavigationBarHelper+AttrRestoration.swift */, 162 | C455E7472058CEAB00A3211D /* UIViewController+Swizzle.swift */, 163 | C454316D21391700002BF607 /* UINavigationBar+Swizzle.swift */, 164 | C454316F213917EF002BF607 /* Utilities.swift */, 165 | C455E7342057EE2E00A3211D /* NavigationBarBackgroundHelper.h */, 166 | C455E7352057EE2E00A3211D /* Info.plist */, 167 | ); 168 | path = NavigationBarHelper; 169 | sourceTree = ""; 170 | }; 171 | /* End PBXGroup section */ 172 | 173 | /* Begin PBXHeadersBuildPhase section */ 174 | C455E72F2057EE2E00A3211D /* Headers */ = { 175 | isa = PBXHeadersBuildPhase; 176 | buildActionMask = 2147483647; 177 | files = ( 178 | C455E7362057EE2E00A3211D /* NavigationBarBackgroundHelper.h in Headers */, 179 | ); 180 | runOnlyForDeploymentPostprocessing = 0; 181 | }; 182 | /* End PBXHeadersBuildPhase section */ 183 | 184 | /* Begin PBXNativeTarget section */ 185 | C42C1D682046CB44004B33D2 /* NavigationBarHelperDemo */ = { 186 | isa = PBXNativeTarget; 187 | buildConfigurationList = C42C1D7B2046CB44004B33D2 /* Build configuration list for PBXNativeTarget "NavigationBarHelperDemo" */; 188 | buildPhases = ( 189 | C42C1D652046CB44004B33D2 /* Sources */, 190 | C42C1D662046CB44004B33D2 /* Frameworks */, 191 | C42C1D672046CB44004B33D2 /* Resources */, 192 | C455E73E2057EE2E00A3211D /* Embed Frameworks */, 193 | ); 194 | buildRules = ( 195 | ); 196 | dependencies = ( 197 | C455E7382057EE2E00A3211D /* PBXTargetDependency */, 198 | ); 199 | name = NavigationBarHelperDemo; 200 | productName = NavigationBarTransitionHandler; 201 | productReference = C42C1D692046CB44004B33D2 /* NavigationBarHelperDemo.app */; 202 | productType = "com.apple.product-type.application"; 203 | }; 204 | C455E7312057EE2E00A3211D /* NavigationBarHelper */ = { 205 | isa = PBXNativeTarget; 206 | buildConfigurationList = C455E73B2057EE2E00A3211D /* Build configuration list for PBXNativeTarget "NavigationBarHelper" */; 207 | buildPhases = ( 208 | C455E72D2057EE2E00A3211D /* Sources */, 209 | C455E72E2057EE2E00A3211D /* Frameworks */, 210 | C455E72F2057EE2E00A3211D /* Headers */, 211 | C455E7302057EE2E00A3211D /* Resources */, 212 | ); 213 | buildRules = ( 214 | ); 215 | dependencies = ( 216 | ); 217 | name = NavigationBarHelper; 218 | productName = NavigationBarBackgroundHelper; 219 | productReference = C455E7322057EE2E00A3211D /* NavigationBarHelper.framework */; 220 | productType = "com.apple.product-type.framework"; 221 | }; 222 | /* End PBXNativeTarget section */ 223 | 224 | /* Begin PBXProject section */ 225 | C42C1D612046CB44004B33D2 /* Project object */ = { 226 | isa = PBXProject; 227 | attributes = { 228 | LastSwiftUpdateCheck = 0920; 229 | LastUpgradeCheck = 0930; 230 | ORGANIZATIONNAME = com.jerry; 231 | TargetAttributes = { 232 | C42C1D682046CB44004B33D2 = { 233 | CreatedOnToolsVersion = 9.2; 234 | LastSwiftMigration = 1020; 235 | ProvisioningStyle = Automatic; 236 | }; 237 | C455E7312057EE2E00A3211D = { 238 | CreatedOnToolsVersion = 9.2; 239 | LastSwiftMigration = 1020; 240 | ProvisioningStyle = Automatic; 241 | }; 242 | }; 243 | }; 244 | buildConfigurationList = C42C1D642046CB44004B33D2 /* Build configuration list for PBXProject "NavigationBarHelper" */; 245 | compatibilityVersion = "Xcode 8.0"; 246 | developmentRegion = en; 247 | hasScannedForEncodings = 0; 248 | knownRegions = ( 249 | en, 250 | Base, 251 | ); 252 | mainGroup = C42C1D602046CB44004B33D2; 253 | productRefGroup = C42C1D6A2046CB44004B33D2 /* Products */; 254 | projectDirPath = ""; 255 | projectRoot = ""; 256 | targets = ( 257 | C42C1D682046CB44004B33D2 /* NavigationBarHelperDemo */, 258 | C455E7312057EE2E00A3211D /* NavigationBarHelper */, 259 | ); 260 | }; 261 | /* End PBXProject section */ 262 | 263 | /* Begin PBXResourcesBuildPhase section */ 264 | C42C1D672046CB44004B33D2 /* Resources */ = { 265 | isa = PBXResourcesBuildPhase; 266 | buildActionMask = 2147483647; 267 | files = ( 268 | C42C1D772046CB44004B33D2 /* LaunchScreen.storyboard in Resources */, 269 | C42C1D742046CB44004B33D2 /* Assets.xcassets in Resources */, 270 | C455E72B2057E83400A3211D /* README.md in Resources */, 271 | C42C1D722046CB44004B33D2 /* Main.storyboard in Resources */, 272 | C455E72C2057E83400A3211D /* LICENSE in Resources */, 273 | ); 274 | runOnlyForDeploymentPostprocessing = 0; 275 | }; 276 | C455E7302057EE2E00A3211D /* Resources */ = { 277 | isa = PBXResourcesBuildPhase; 278 | buildActionMask = 2147483647; 279 | files = ( 280 | ); 281 | runOnlyForDeploymentPostprocessing = 0; 282 | }; 283 | /* End PBXResourcesBuildPhase section */ 284 | 285 | /* Begin PBXSourcesBuildPhase section */ 286 | C42C1D652046CB44004B33D2 /* Sources */ = { 287 | isa = PBXSourcesBuildPhase; 288 | buildActionMask = 2147483647; 289 | files = ( 290 | C424D7F62060E7C6006B9697 /* UINavigationController+Swizzle.swift in Sources */, 291 | C42C1D6F2046CB44004B33D2 /* HomeViewController.swift in Sources */, 292 | C42C1D6D2046CB44004B33D2 /* AppDelegate.swift in Sources */, 293 | C424D7F52060E7C6006B9697 /* UIViewController+PopInterrupter.swift in Sources */, 294 | C425CC7021D5EFB50062F919 /* HideNavigationBarViewController.swift in Sources */, 295 | C47A328120517B3600C46FD5 /* AccountViewController.swift in Sources */, 296 | C4A681D420BCF9BA00F3EDD7 /* TimelineViewController.swift in Sources */, 297 | C47A327F2051781F00C46FD5 /* ListViewController.swift in Sources */, 298 | C403446320525890002BF6AC /* SetViewController.swift in Sources */, 299 | ); 300 | runOnlyForDeploymentPostprocessing = 0; 301 | }; 302 | C455E72D2057EE2E00A3211D /* Sources */ = { 303 | isa = PBXSourcesBuildPhase; 304 | buildActionMask = 2147483647; 305 | files = ( 306 | C4543170213917EF002BF607 /* Utilities.swift in Sources */, 307 | C454316E21391700002BF607 /* UINavigationBar+Swizzle.swift in Sources */, 308 | C455E7462058CE1200A3211D /* NavigationBarHelper+AttrRestoration.swift in Sources */, 309 | C455E7482058CEAB00A3211D /* UIViewController+Swizzle.swift in Sources */, 310 | C455E7432057EE9800A3211D /* NavigationBarHelper.swift in Sources */, 311 | C455E7442057EE9800A3211D /* NavigationBarBackgroundView.swift in Sources */, 312 | ); 313 | runOnlyForDeploymentPostprocessing = 0; 314 | }; 315 | /* End PBXSourcesBuildPhase section */ 316 | 317 | /* Begin PBXTargetDependency section */ 318 | C455E7382057EE2E00A3211D /* PBXTargetDependency */ = { 319 | isa = PBXTargetDependency; 320 | target = C455E7312057EE2E00A3211D /* NavigationBarHelper */; 321 | targetProxy = C455E7372057EE2E00A3211D /* PBXContainerItemProxy */; 322 | }; 323 | /* End PBXTargetDependency section */ 324 | 325 | /* Begin PBXVariantGroup section */ 326 | C42C1D702046CB44004B33D2 /* Main.storyboard */ = { 327 | isa = PBXVariantGroup; 328 | children = ( 329 | C42C1D712046CB44004B33D2 /* Base */, 330 | ); 331 | name = Main.storyboard; 332 | sourceTree = ""; 333 | }; 334 | C42C1D752046CB44004B33D2 /* LaunchScreen.storyboard */ = { 335 | isa = PBXVariantGroup; 336 | children = ( 337 | C42C1D762046CB44004B33D2 /* Base */, 338 | ); 339 | name = LaunchScreen.storyboard; 340 | sourceTree = ""; 341 | }; 342 | /* End PBXVariantGroup section */ 343 | 344 | /* Begin XCBuildConfiguration section */ 345 | C42C1D792046CB44004B33D2 /* Debug */ = { 346 | isa = XCBuildConfiguration; 347 | buildSettings = { 348 | ALWAYS_SEARCH_USER_PATHS = NO; 349 | CLANG_ANALYZER_NONNULL = YES; 350 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 351 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 352 | CLANG_CXX_LIBRARY = "libc++"; 353 | CLANG_ENABLE_MODULES = YES; 354 | CLANG_ENABLE_OBJC_ARC = YES; 355 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 356 | CLANG_WARN_BOOL_CONVERSION = YES; 357 | CLANG_WARN_COMMA = YES; 358 | CLANG_WARN_CONSTANT_CONVERSION = YES; 359 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 360 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 361 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 362 | CLANG_WARN_EMPTY_BODY = YES; 363 | CLANG_WARN_ENUM_CONVERSION = YES; 364 | CLANG_WARN_INFINITE_RECURSION = YES; 365 | CLANG_WARN_INT_CONVERSION = YES; 366 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 367 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 368 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 369 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 370 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 371 | CLANG_WARN_STRICT_PROTOTYPES = YES; 372 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 373 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 374 | CLANG_WARN_UNREACHABLE_CODE = YES; 375 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 376 | CODE_SIGN_IDENTITY = "iPhone Developer"; 377 | COPY_PHASE_STRIP = NO; 378 | DEBUG_INFORMATION_FORMAT = dwarf; 379 | ENABLE_STRICT_OBJC_MSGSEND = YES; 380 | ENABLE_TESTABILITY = YES; 381 | GCC_C_LANGUAGE_STANDARD = gnu11; 382 | GCC_DYNAMIC_NO_PIC = NO; 383 | GCC_NO_COMMON_BLOCKS = YES; 384 | GCC_OPTIMIZATION_LEVEL = 0; 385 | GCC_PREPROCESSOR_DEFINITIONS = ( 386 | "DEBUG=1", 387 | "$(inherited)", 388 | ); 389 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 390 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 391 | GCC_WARN_UNDECLARED_SELECTOR = YES; 392 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 393 | GCC_WARN_UNUSED_FUNCTION = YES; 394 | GCC_WARN_UNUSED_VARIABLE = YES; 395 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 396 | MTL_ENABLE_DEBUG_INFO = YES; 397 | ONLY_ACTIVE_ARCH = YES; 398 | SDKROOT = iphoneos; 399 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 400 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 401 | }; 402 | name = Debug; 403 | }; 404 | C42C1D7A2046CB44004B33D2 /* Release */ = { 405 | isa = XCBuildConfiguration; 406 | buildSettings = { 407 | ALWAYS_SEARCH_USER_PATHS = NO; 408 | CLANG_ANALYZER_NONNULL = YES; 409 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 410 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 411 | CLANG_CXX_LIBRARY = "libc++"; 412 | CLANG_ENABLE_MODULES = YES; 413 | CLANG_ENABLE_OBJC_ARC = YES; 414 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 415 | CLANG_WARN_BOOL_CONVERSION = YES; 416 | CLANG_WARN_COMMA = YES; 417 | CLANG_WARN_CONSTANT_CONVERSION = YES; 418 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 419 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 420 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 421 | CLANG_WARN_EMPTY_BODY = YES; 422 | CLANG_WARN_ENUM_CONVERSION = YES; 423 | CLANG_WARN_INFINITE_RECURSION = YES; 424 | CLANG_WARN_INT_CONVERSION = YES; 425 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 426 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 427 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 428 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 429 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 430 | CLANG_WARN_STRICT_PROTOTYPES = YES; 431 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 432 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 433 | CLANG_WARN_UNREACHABLE_CODE = YES; 434 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 435 | CODE_SIGN_IDENTITY = "iPhone Developer"; 436 | COPY_PHASE_STRIP = NO; 437 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 438 | ENABLE_NS_ASSERTIONS = NO; 439 | ENABLE_STRICT_OBJC_MSGSEND = YES; 440 | GCC_C_LANGUAGE_STANDARD = gnu11; 441 | GCC_NO_COMMON_BLOCKS = YES; 442 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 443 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 444 | GCC_WARN_UNDECLARED_SELECTOR = YES; 445 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 446 | GCC_WARN_UNUSED_FUNCTION = YES; 447 | GCC_WARN_UNUSED_VARIABLE = YES; 448 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 449 | MTL_ENABLE_DEBUG_INFO = NO; 450 | SDKROOT = iphoneos; 451 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 452 | VALIDATE_PRODUCT = YES; 453 | }; 454 | name = Release; 455 | }; 456 | C42C1D7C2046CB44004B33D2 /* Debug */ = { 457 | isa = XCBuildConfiguration; 458 | buildSettings = { 459 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 460 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 461 | CODE_SIGN_STYLE = Automatic; 462 | INFOPLIST_FILE = NavigationBarHelperDemo/Info.plist; 463 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 464 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 465 | PRODUCT_BUNDLE_IDENTIFIER = com.jerry.NavigationBarTransitionHandler; 466 | PRODUCT_NAME = "$(TARGET_NAME)"; 467 | SWIFT_VERSION = 5.0; 468 | TARGETED_DEVICE_FAMILY = "1,2"; 469 | }; 470 | name = Debug; 471 | }; 472 | C42C1D7D2046CB44004B33D2 /* Release */ = { 473 | isa = XCBuildConfiguration; 474 | buildSettings = { 475 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 476 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 477 | CODE_SIGN_STYLE = Automatic; 478 | INFOPLIST_FILE = NavigationBarHelperDemo/Info.plist; 479 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 480 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 481 | PRODUCT_BUNDLE_IDENTIFIER = com.jerry.NavigationBarTransitionHandler; 482 | PRODUCT_NAME = "$(TARGET_NAME)"; 483 | SWIFT_VERSION = 5.0; 484 | TARGETED_DEVICE_FAMILY = "1,2"; 485 | }; 486 | name = Release; 487 | }; 488 | C455E73C2057EE2E00A3211D /* Debug */ = { 489 | isa = XCBuildConfiguration; 490 | buildSettings = { 491 | CLANG_ENABLE_MODULES = YES; 492 | CODE_SIGN_IDENTITY = ""; 493 | CODE_SIGN_STYLE = Automatic; 494 | CURRENT_PROJECT_VERSION = 1; 495 | DEFINES_MODULE = YES; 496 | DYLIB_COMPATIBILITY_VERSION = 1; 497 | DYLIB_CURRENT_VERSION = 1; 498 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 499 | INFOPLIST_FILE = NavigationBarHelper/Info.plist; 500 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 501 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 502 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 503 | PRODUCT_BUNDLE_IDENTIFIER = com.jerry.NavigationBarBackgroundHelper; 504 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 505 | SKIP_INSTALL = YES; 506 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 507 | SWIFT_VERSION = 5.0; 508 | TARGETED_DEVICE_FAMILY = "1,2"; 509 | VERSIONING_SYSTEM = "apple-generic"; 510 | VERSION_INFO_PREFIX = ""; 511 | }; 512 | name = Debug; 513 | }; 514 | C455E73D2057EE2E00A3211D /* Release */ = { 515 | isa = XCBuildConfiguration; 516 | buildSettings = { 517 | CLANG_ENABLE_MODULES = YES; 518 | CODE_SIGN_IDENTITY = ""; 519 | CODE_SIGN_STYLE = Automatic; 520 | CURRENT_PROJECT_VERSION = 1; 521 | DEFINES_MODULE = YES; 522 | DYLIB_COMPATIBILITY_VERSION = 1; 523 | DYLIB_CURRENT_VERSION = 1; 524 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 525 | INFOPLIST_FILE = NavigationBarHelper/Info.plist; 526 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 527 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 528 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 529 | PRODUCT_BUNDLE_IDENTIFIER = com.jerry.NavigationBarBackgroundHelper; 530 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 531 | SKIP_INSTALL = YES; 532 | SWIFT_VERSION = 5.0; 533 | TARGETED_DEVICE_FAMILY = "1,2"; 534 | VERSIONING_SYSTEM = "apple-generic"; 535 | VERSION_INFO_PREFIX = ""; 536 | }; 537 | name = Release; 538 | }; 539 | /* End XCBuildConfiguration section */ 540 | 541 | /* Begin XCConfigurationList section */ 542 | C42C1D642046CB44004B33D2 /* Build configuration list for PBXProject "NavigationBarHelper" */ = { 543 | isa = XCConfigurationList; 544 | buildConfigurations = ( 545 | C42C1D792046CB44004B33D2 /* Debug */, 546 | C42C1D7A2046CB44004B33D2 /* Release */, 547 | ); 548 | defaultConfigurationIsVisible = 0; 549 | defaultConfigurationName = Release; 550 | }; 551 | C42C1D7B2046CB44004B33D2 /* Build configuration list for PBXNativeTarget "NavigationBarHelperDemo" */ = { 552 | isa = XCConfigurationList; 553 | buildConfigurations = ( 554 | C42C1D7C2046CB44004B33D2 /* Debug */, 555 | C42C1D7D2046CB44004B33D2 /* Release */, 556 | ); 557 | defaultConfigurationIsVisible = 0; 558 | defaultConfigurationName = Release; 559 | }; 560 | C455E73B2057EE2E00A3211D /* Build configuration list for PBXNativeTarget "NavigationBarHelper" */ = { 561 | isa = XCConfigurationList; 562 | buildConfigurations = ( 563 | C455E73C2057EE2E00A3211D /* Debug */, 564 | C455E73D2057EE2E00A3211D /* Release */, 565 | ); 566 | defaultConfigurationIsVisible = 0; 567 | defaultConfigurationName = Release; 568 | }; 569 | /* End XCConfigurationList section */ 570 | }; 571 | rootObject = C42C1D612046CB44004B33D2 /* Project object */; 572 | } 573 | -------------------------------------------------------------------------------- /NavigationBarHelper.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /NavigationBarHelper.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /NavigationBarHelper/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /NavigationBarHelper/NavigationBarBackgroundHelper.h: -------------------------------------------------------------------------------- 1 | // 2 | // NavigationBarHelper.h 3 | // NavigationBarHelper 4 | // 5 | // Created by Jerry Wong on 2018/3/13. 6 | // Copyright © 2018年 com.jerry. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for NavigationBarHelper. 12 | FOUNDATION_EXPORT double NavigationBarHelperVersionNumber; 13 | 14 | //! Project version string for NavigationBarHelper. 15 | FOUNDATION_EXPORT const unsigned char NavigationBarHelperVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /NavigationBarHelper/NavigationBarBackgroundView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NavigationBarBackgroundView.swift 3 | // 4 | // Copyright (c) 2015 Jerry Wong 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | import UIKit 25 | 26 | open class NavigationBarBackgroundView: UIView { 27 | 28 | public override init(frame: CGRect) { 29 | super.init(frame: frame) 30 | 31 | contentView.frame = CGRect(x: 0, y: 0, width: frame.size.width, height: frame.size.height) 32 | contentView.autoresizingMask = [.flexibleWidth, .flexibleHeight] 33 | addSubview(contentView) 34 | 35 | shadowImageView.frame = CGRect(x: 0, y: frame.size.height - shadowHeight, width: frame.size.width, height: shadowHeight) 36 | shadowImageView.autoresizingMask = [.flexibleWidth, .flexibleTopMargin] 37 | addSubview(shadowImageView) 38 | } 39 | 40 | convenience init(navigationBar: UINavigationBar) { 41 | self.init(frame: navigationBar.bounds) 42 | update(withNavigationBar: navigationBar) 43 | } 44 | 45 | required public init?(coder aDecoder: NSCoder) { 46 | fatalError("init(coder:) has not been implemented") 47 | } 48 | 49 | open func update(withNavigationBar bar: UINavigationBar) { 50 | let backgroundImg = bar.backgroundImage(for: .default) 51 | frame = bar.bounds 52 | update(withBackgroundImage: backgroundImg, 53 | barTintColor: bar.barTintColor, 54 | isTranslucent: bar.isTranslucent, 55 | barStyle: bar.barStyle, 56 | shadowImage: bar.shadowImage) 57 | } 58 | 59 | open func update(withBackgroundImage image: UIImage?, 60 | barTintColor: UIColor?, 61 | isTranslucent: Bool, 62 | barStyle: UIBarStyle, 63 | shadowImage: UIImage?) { 64 | 65 | contentView.subviews.forEach{ $0.removeFromSuperview() } 66 | var mShadowImage = shadowImage 67 | //A bool indicates whether the shadow is on top of the content view. 68 | var isShadowTop = true 69 | if image == nil { 70 | if let barTintColor = barTintColor { 71 | if isTranslucent { 72 | let blurView = UIVisualEffectView(effect: UIBlurEffect(style: .light)) 73 | blurView.frame = contentView.bounds 74 | blurView.autoresizingMask = [.flexibleWidth, .flexibleHeight] 75 | self.addSubview(blurView) 76 | 77 | blurView.contentView.backgroundColor = UIColor.init(white: 0.97, alpha: 0.5) 78 | let tintColorView = UIView(frame: blurView.bounds) 79 | tintColorView.backgroundColor = barTintColor 80 | tintColorView.alpha = 0.85 81 | tintColorView.autoresizingMask = [.flexibleWidth, .flexibleHeight] 82 | blurView.contentView.addSubview(tintColorView) 83 | } else { 84 | self.backgroundColor = barTintColor 85 | } 86 | } else { 87 | if isTranslucent { 88 | let blurView = UIVisualEffectView(effect: UIBlurEffect(style: barStyle.defaultBlurEffectConfig.0)) 89 | blurView.contentView.backgroundColor = barStyle.defaultBlurEffectConfig.1 90 | //It turns out that when the bar is dark, the contentView makes the backgroundView darker. So we remove it. 91 | if barStyle.defaultBlurEffectConfig.0 == .dark { 92 | blurView.contentView.removeFromSuperview() 93 | } 94 | blurView.frame = contentView.bounds 95 | blurView.autoresizingMask = [.flexibleWidth, .flexibleHeight] 96 | self.addSubview(blurView) 97 | } else { 98 | self.backgroundColor = UIColor(white: (barStyle == .default ? 1.0 : 0.0), alpha: 1.0) 99 | } 100 | } 101 | mShadowImage = UIImage(color: barStyle.shadowColor) 102 | isShadowTop = isTranslucent 103 | } else { 104 | let imageView = UIImageView(image: image) 105 | imageView.frame = contentView.bounds 106 | imageView.autoresizingMask = [.flexibleWidth, .flexibleHeight] 107 | self.addSubview(imageView) 108 | mShadowImage = shadowImage ?? UIImage(color: barStyle.shadowColor) 109 | isShadowTop = true 110 | } 111 | 112 | bringSubviewToFront(isShadowTop ? shadowImageView : contentView) 113 | shadowImageView.image = mShadowImage 114 | } 115 | 116 | private let shadowHeight = 1.0 / UIScreen.main.scale 117 | 118 | private let contentView = UIView() 119 | 120 | private let shadowImageView = UIImageView() 121 | 122 | } 123 | -------------------------------------------------------------------------------- /NavigationBarHelper/NavigationBarHelper+AttrRestoration.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NavigationBarHelper+AttrRestoration.swift 3 | // 4 | // Copyright (c) 2015 Jerry Wong 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | import UIKit 25 | 26 | public extension NavigationBarHelper { 27 | 28 | typealias BackgroundAttr = (backgroundImages: [UIBarMetrics: UIImage], shadowImage: UIImage?, barTintColor: UIColor?, isTranslucent: Bool) 29 | 30 | typealias ForegroundAttr = (tintColor: UIColor?, barStyle: UIBarStyle, titleAttributes: [NSAttributedString.Key: Any]?) 31 | 32 | func stashBackgroundAttr(for bar: UINavigationBar) { 33 | var backgroundImages = [UIBarMetrics: UIImage]() 34 | [UIBarMetrics.default, UIBarMetrics.compact, UIBarMetrics.defaultPrompt, UIBarMetrics.compactPrompt].forEach { 35 | guard let img = bar.backgroundImage(for: $0) else { 36 | return 37 | } 38 | backgroundImages[$0] = img 39 | } 40 | 41 | backgroundAttr = (backgroundImages, bar.shadowImage, bar.barTintColor, bar.isTranslucent) 42 | } 43 | 44 | func restoreBackgroundAttr(for bar: UINavigationBar) { 45 | guard var attr = backgroundAttr else { 46 | return 47 | } 48 | 49 | let notifier = viewController as? NavigationBarHelperDelegate 50 | notifier?.willRestore(backgroundAttr: &attr) 51 | 52 | if attr.backgroundImages.count > 0 { 53 | attr.backgroundImages.forEach { bar.setBackgroundImage($0.1, for: $0.0) } 54 | } else { 55 | [.default, .compact, .defaultPrompt, .compactPrompt].forEach { bar.setBackgroundImage(nil, for: $0) } 56 | } 57 | 58 | bar.shadowImage = attr.shadowImage 59 | bar.isTranslucent = attr.isTranslucent 60 | bar.barTintColor = attr.barTintColor 61 | 62 | notifier?.didRestore(backgroundAttr: attr) 63 | } 64 | 65 | func stashForegroundAttr(for bar: UINavigationBar) { 66 | foregroundAttr = (bar.tintColor, bar.barStyle, bar.titleTextAttributes) 67 | } 68 | 69 | func restoreForegroundAttr(for bar: UINavigationBar) { 70 | guard var attr = foregroundAttr else { 71 | return 72 | } 73 | 74 | let notifier = viewController as? NavigationBarHelperDelegate 75 | notifier?.willRestore(foregroundAttr: &attr) 76 | 77 | bar.tintColor = attr.tintColor 78 | bar.titleTextAttributes = attr.titleAttributes 79 | bar.barStyle = attr.barStyle 80 | 81 | notifier?.didRestore(foregroundAttr: attr) 82 | 83 | } 84 | 85 | internal func fixNavigationTitleView(for bar: UINavigationBar) { 86 | //It turns out that when the transition is ongoing, the barStyle does not change the title label correctly. 87 | //So we have to change the title color manually when the titleAttributes are not set. 88 | 89 | guard bar.titleTextAttributes == nil, let barForegroundContentClass = NSClassFromString("_UINavigationBarContentView") else { 90 | return 91 | } 92 | 93 | for subView in bar.subviews { 94 | if subView.isKind(of: barForegroundContentClass) { 95 | for contentView in subView.subviews { 96 | if let label = contentView as? UILabel { 97 | label.textColor = bar.barStyle == .default ? UIColor.black : UIColor.white 98 | break 99 | } 100 | } 101 | break 102 | } 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /NavigationBarHelper/NavigationBarHelper.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NavigationBarHelper.swift 3 | // 4 | // Copyright (c) 2015 Jerry Wong 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | import UIKit 25 | 26 | extension UIViewController { 27 | 28 | open var navigationBarHelper: NavigationBarHelper { 29 | 30 | get { 31 | var handler = getStoredNavigationBarHelper() 32 | if handler == nil { 33 | handler = NavigationBarHelper(viewController: self) 34 | self.navigationBarHelper = handler! 35 | } 36 | return handler! 37 | } 38 | 39 | set { 40 | objc_setAssociatedObject(self, &BarHelperKey, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) 41 | } 42 | 43 | } 44 | 45 | var previousNavigationBarHelper: NavigationBarHelper? { 46 | get { 47 | guard let vcs = navigationController?.viewControllers, vcs.count >= 2 else { 48 | return nil 49 | } 50 | return vcs[vcs.count - 2].getStoredNavigationBarHelper() 51 | } 52 | } 53 | 54 | func getStoredNavigationBarHelper() -> NavigationBarHelper? { 55 | return objc_getAssociatedObject(self, &BarHelperKey) as? NavigationBarHelper 56 | } 57 | 58 | } 59 | 60 | public protocol NavigationBarHelperDelegate { 61 | 62 | /// Called before the mirror view capturing the bar's background attribute. 63 | /// Modify the backgroundAttr if it is not your appetite 64 | func willRestore(backgroundAttr: inout NavigationBarHelper.BackgroundAttr) 65 | 66 | /// Called after the mirror view capturing the bar's background attribute. 67 | /// It is the best time for you to do additional change to the bar's background attr. 68 | /// After this function is called, the mirror background view will synchronize with the bar's background. 69 | func didRestore(backgroundAttr: NavigationBarHelper.BackgroundAttr) 70 | 71 | /// Called before the navigation bar's foreground attribute being restored, especially when the viewController's appearing. 72 | /// Modify the foregroundAttr if it is not your appetite 73 | func willRestore(foregroundAttr: inout NavigationBarHelper.ForegroundAttr) 74 | 75 | /// Called after the navigation bar's foreground attribute being restored, especially when the viewController's appearing. 76 | /// Do additional change if you have modified the navigation bar out of the performNavigationBarUpdates scope.(e.g, you have set the bar tint color according to scrollview offset) 77 | func didRestore(foregroundAttr: NavigationBarHelper.ForegroundAttr) 78 | 79 | } 80 | 81 | public final class NavigationBarHelper { 82 | 83 | /// A type indicates the transition style for the navigation bar 84 | public enum TranstionStyle { 85 | 86 | ///iOS' default style. perform a fade like transition 87 | case system 88 | 89 | ///android default style. The navigation bar is attached to the viewController. 90 | case followPage 91 | 92 | } 93 | 94 | public static var transitionStyle = TranstionStyle.system 95 | 96 | public private(set) var view: NavigationBarBackgroundView? 97 | 98 | init(viewController: UIViewController) { 99 | self.viewController = viewController 100 | } 101 | 102 | ///This function is to be called in viewDidLoad. 103 | ///Apis to change the navigation bar should be called within this scope. 104 | ///After called,any attribute (background image/tintColor/barTintColor/barStyle etc) will be remembered by the library. 105 | ///It will create a mirror background view of the navigation bar (auto managed) and clear the bar background (to provide a smooth transition). 106 | ///Any change to the navigation bar's background (background image/barTintColor/barStyle/shadowImage) within the scope will be syncronized with the mirror view. 107 | public func perform(_ action: ((UINavigationBar) -> ())?) { 108 | guard let bar = viewController?.navigationController?.navigationBar else { 109 | return 110 | } 111 | beginUpdate(with: bar) 112 | action?(bar) 113 | endUpdate(with: bar) 114 | } 115 | 116 | public func setNeedsLayout() { 117 | guard let vc = viewController else { 118 | return 119 | } 120 | 121 | var insetsTop = CGFloat(0) 122 | if #available(iOS 11.0, *) { 123 | insetsTop = max(vc.view.safeAreaInsets.top, vc.navigationController?.navigationBar.frame.size.height ?? 0) 124 | } else { 125 | insetsTop = max(vc.topLayoutGuide.length, vc.navigationController?.navigationBar.frame.size.height ?? 0) 126 | } 127 | view?.frame = CGRect(x: 0, y: 0 + (view?.transform.ty ?? 0), width: view?.frame.size.width ?? 0, height: insetsTop) 128 | } 129 | 130 | func synchronizeForegroundAttr() { 131 | guard let nc = viewController?.navigationController else { 132 | return 133 | } 134 | let bar = nc.navigationBar 135 | restoreForegroundAttr(for: bar) 136 | view?.isHidden = isNavigationBarHidden 137 | } 138 | 139 | func snapshotNavigationRegion() { 140 | guard 141 | let nc = viewController?.navigationController, 142 | let view = view, 143 | nc.isViewLoaded && !view.isHidden else { 144 | return 145 | } 146 | if let snapshotView = nc.view.resizableSnapshotView(from: CGRect(origin: CGPoint.zero, size: view.frame.size), afterScreenUpdates: false, withCapInsets: UIEdgeInsets.zero) { 147 | snapshotView.tag = NavigationRegionSnapshotViewTag 148 | snapshotView.autoresizingMask = [.flexibleWidth, .flexibleHeight] 149 | view.addSubview(snapshotView) 150 | } 151 | } 152 | 153 | func removeNavigationRegionSnapshot() { 154 | guard let view = view, !view.isHidden else { 155 | return 156 | } 157 | let snapshotView = view.viewWithTag(NavigationRegionSnapshotViewTag) 158 | snapshotView?.removeFromSuperview() 159 | } 160 | 161 | func clearForegroundAttr(isRestoreEnabled: Bool) { 162 | if isRestoreEnabled { 163 | let title = viewController?.navigationItem.title 164 | let titleView = viewController?.navigationItem.titleView 165 | let prompt = viewController?.navigationItem.prompt 166 | let leftBarButtonItems = viewController?.navigationItem.leftBarButtonItems 167 | let rightBarButtonItem = viewController?.navigationItem.rightBarButtonItem 168 | let isHidesBackButton = viewController?.navigationItem.hidesBackButton ?? false 169 | 170 | restoreClearedForegroundOperation = { [weak viewController] in 171 | viewController?.navigationItem.title = title 172 | viewController?.navigationItem.titleView = titleView 173 | viewController?.navigationItem.prompt = prompt 174 | viewController?.navigationItem.leftBarButtonItems = leftBarButtonItems 175 | viewController?.navigationItem.rightBarButtonItem = rightBarButtonItem 176 | viewController?.navigationItem.setHidesBackButton(isHidesBackButton, animated: false) 177 | } 178 | } 179 | viewController?.navigationController?.navigationBar.tintColor = UIColor.clear 180 | viewController?.navigationItem.title = nil 181 | viewController?.navigationItem.titleView = nil 182 | viewController?.navigationItem.prompt = nil 183 | viewController?.navigationItem.leftBarButtonItems = nil 184 | viewController?.navigationItem.rightBarButtonItem = nil 185 | viewController?.navigationItem.setHidesBackButton(true, animated: false) 186 | } 187 | 188 | func restoreClearedForegroundAttr() { 189 | restoreClearedForegroundOperation?() 190 | restoreClearedForegroundOperation = nil 191 | } 192 | 193 | var backgroundAttr: BackgroundAttr? 194 | 195 | var foregroundAttr: ForegroundAttr? 196 | 197 | var isNavigationBarHidden = false 198 | 199 | var isNavigationRegionSnapshotted: Bool { 200 | get { 201 | return view?.viewWithTag(NavigationRegionSnapshotViewTag) != nil 202 | } 203 | } 204 | 205 | weak var viewController: UIViewController? 206 | 207 | var keyPathObservations: [NSKeyValueObservation]? 208 | 209 | var restoreClearedForegroundOperation: (() -> ())? 210 | 211 | } 212 | 213 | extension NavigationBarHelper { 214 | 215 | public class func load() { 216 | _ = __init__ 217 | } 218 | 219 | } 220 | 221 | extension NavigationBarHelper { 222 | 223 | private func beginUpdate(with bar: UINavigationBar) { 224 | 225 | guard let previousHelper = viewController?.previousNavigationBarHelper else { 226 | return 227 | } 228 | previousHelper.restoreBackgroundAttr(for: bar) 229 | } 230 | 231 | private func endUpdate(with bar: UINavigationBar) { 232 | guard viewController?.isViewLoaded ?? false, let containerView = viewController?.view else { 233 | return 234 | } 235 | 236 | isNavigationBarHidden = viewController?.navigationController?.isNavigationBarHidden ?? false 237 | 238 | if !isNavigationBarHidden { 239 | if view == nil { 240 | view = NavigationBarBackgroundView(navigationBar: bar) 241 | view?.autoresizingMask = [.flexibleWidth] 242 | } else { 243 | view?.update(withNavigationBar: bar) 244 | } 245 | containerView.addSubview(view!) 246 | if let scrollView = containerView as? UIScrollView { 247 | keyPathObservations = [ 248 | scrollView.observe(\.contentOffset, options: .new, changeHandler: { [weak self] (scrollView, change) in 249 | self?.view?.transform = CGAffineTransform(translationX: 0, y: change.newValue?.y ?? 0) 250 | }) 251 | ] 252 | } 253 | } else { 254 | //Here, we set the navigation bar visible, to provide a smooth transition. 255 | //To confirm to the user's set, we play a trick to fade that the navigation bar is hidden. 256 | //To do so, we clear all the foreground attr and set the bgView hidden. 257 | //On iOS 11, we provide an negative insets top to cancel out the navigation bar's position 258 | viewController?.navigationController?.setNavigationBarHidden(false, animated: false) 259 | if #available(iOS 11.0, *) { 260 | viewController?.additionalSafeAreaInsets = UIEdgeInsets(top: -(viewController?.navigationController?.navigationBar.bounds.height ?? 0), left: 0, bottom: 0, right: 0) 261 | } else { 262 | //unsupported yet 263 | } 264 | clearForegroundAttr(isRestoreEnabled: false) 265 | } 266 | 267 | stashForegroundAttr(for: bar) 268 | stashBackgroundAttr(for: bar) 269 | [.default, .compact, .defaultPrompt, .compactPrompt].forEach{ bar.setBackgroundImage(UIImage.transparent, for: $0) } 270 | bar.shadowImage = UIImage.transparent 271 | bar.isTranslucent = true 272 | } 273 | 274 | } 275 | 276 | fileprivate let __init__: Bool = { 277 | do { 278 | if #available(iOS 11.0, *) { 279 | try UIViewController.exchange(#selector(UIViewController.viewSafeAreaInsetsDidChange), withSEL: #selector(UIViewController.jw_swizzling_UIViewController_viewSafeAreaInsetsDidChange)) 280 | } else { 281 | try UIViewController.exchange(#selector(UIViewController.viewWillLayoutSubviews), withSEL: #selector(UIViewController.jw_swizzling_UIViewController_viewWillLayoutSubViews)) 282 | } 283 | try UIViewController.exchange(#selector(UIViewController.viewWillAppear(_:)), withSEL: #selector(UIViewController.jw_swizzling_UIViewController_viewWillAppear(_:))) 284 | try UIViewController.exchange(#selector(UIViewController.viewDidAppear(_:)), withSEL: #selector(UIViewController.jw_swizzling_UIViewController_viewDidAppear(_:))) 285 | try UIViewController.exchange(#selector(UIViewController.viewWillDisappear(_:)), withSEL: #selector(UIViewController.jw_swizzling_UIViewController_viewWillDisappear(_:))) 286 | try UINavigationBar.exchange(#selector(UINavigationBar.hitTest(_:with:)), withSEL: #selector(UINavigationBar.jw_swizzling_UINavigationBar_hitTest(_:with:))) 287 | } catch { 288 | debugPrint(error) 289 | } 290 | return true 291 | }() 292 | 293 | private var BarHelperKey: Void? 294 | 295 | private let NavigationRegionSnapshotViewTag = 1011 296 | -------------------------------------------------------------------------------- /NavigationBarHelper/UINavigationBar+Swizzle.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UINavigationBar+Swizzle.swift 3 | // 4 | // Copyright (c) 2015 Jerry Wong 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | import UIKit 25 | 26 | extension UINavigationBar { 27 | 28 | @objc func jw_swizzling_UINavigationBar_hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { 29 | let ret = self.jw_swizzling_UINavigationBar_hitTest(point, with: event) 30 | return jw_transformHitView(ret) 31 | } 32 | 33 | private func jw_transformHitView(_ sender: UIView?) -> UIView? { 34 | if sender is UIControl || (sender?.gestureRecognizers?.count ?? 0) > 0 { 35 | return sender 36 | } 37 | return nil 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /NavigationBarHelper/UIViewController+Swizzle.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+Swizzle.swift 3 | // 4 | // Copyright (c) 2015 Jerry Wong 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | import UIKit 25 | 26 | extension UIViewController { 27 | 28 | @objc func jw_swizzling_UIViewController_viewWillLayoutSubViews() { 29 | jw_swizzling_UIViewController_viewWillLayoutSubViews() 30 | jw_viewWillLayoutSubViews() 31 | } 32 | 33 | @available(iOS 11.0, *) 34 | @objc func jw_swizzling_UIViewController_viewSafeAreaInsetsDidChange() { 35 | jw_viewSafeAreaInsetsDidChange() 36 | jw_swizzling_UIViewController_viewSafeAreaInsetsDidChange() 37 | } 38 | 39 | @objc func jw_swizzling_UIViewController_viewWillAppear(_ animated: Bool) { 40 | jw_viewWillAppear(animated) 41 | jw_swizzling_UIViewController_viewWillAppear(animated) 42 | } 43 | 44 | @objc func jw_swizzling_UIViewController_viewDidAppear(_ animated: Bool) { 45 | jw_viewDidAppear(animated) 46 | jw_swizzling_UIViewController_viewDidAppear(animated) 47 | } 48 | 49 | @objc func jw_swizzling_UIViewController_viewWillDisappear(_ animated: Bool) { 50 | jw_viewWillDisappear(animated) 51 | jw_swizzling_UIViewController_viewWillDisappear(animated) 52 | } 53 | 54 | private func jw_viewWillLayoutSubViews() { 55 | getStoredNavigationBarHelper()?.setNeedsLayout() 56 | } 57 | 58 | @available(iOS 11.0, *) 59 | private func jw_viewSafeAreaInsetsDidChange() { 60 | getStoredNavigationBarHelper()?.setNeedsLayout() 61 | } 62 | 63 | private func jw_viewWillAppear(_ animated: Bool) { 64 | guard getStoredNavigationBarHelper() != nil else { 65 | return 66 | } 67 | if case .followPage = NavigationBarHelper.transitionStyle { 68 | if !navigationBarHelper.isNavigationRegionSnapshotted { 69 | synchronizeForegroundAttr() 70 | } 71 | navigationController?.setNavigationBarHidden(false, animated: true) 72 | } else { 73 | if animated { 74 | if transitionCoordinator?.isInteractive ?? false {//interactive pop back gesture 75 | if transitionCoordinator?.isCancelled ?? false {//gesture cancelled, fromVc reappeared 76 | synchronizeForegroundAttr() 77 | } else {//gesture ongoing, toVc execute animation 78 | transitionCoordinator?.animate(alongsideTransition: { (ctx) in 79 | self.synchronizeForegroundAttr() 80 | }, completion: { (ctx) in 81 | 82 | }) 83 | } 84 | } else {//non-interactive pop back (click the back item) 85 | UIView.animate(withDuration: TimeInterval(UINavigationController.hideShowBarDuration), animations: { 86 | self.synchronizeForegroundAttr() 87 | if let bar = self.navigationController?.navigationBar { 88 | self.navigationBarHelper.fixNavigationTitleView(for: bar) 89 | } 90 | }) 91 | } 92 | } else {//perform with no animation 93 | synchronizeForegroundAttr() 94 | } 95 | } 96 | } 97 | 98 | private func jw_viewDidAppear(_ animated: Bool) { 99 | guard getStoredNavigationBarHelper() != nil else { 100 | return 101 | } 102 | if case .followPage = NavigationBarHelper.transitionStyle { 103 | navigationBarHelper.removeNavigationRegionSnapshot() 104 | navigationBarHelper.restoreClearedForegroundAttr() 105 | synchronizeForegroundAttr() 106 | } 107 | } 108 | 109 | private func jw_viewWillDisappear(_ animated: Bool) { 110 | guard getStoredNavigationBarHelper() != nil else { 111 | return 112 | } 113 | if case .followPage = NavigationBarHelper.transitionStyle { 114 | navigationBarHelper.snapshotNavigationRegion() 115 | navigationBarHelper.clearForegroundAttr(isRestoreEnabled: true) 116 | navigationController?.setNavigationBarHidden(true, animated: false) 117 | } 118 | 119 | } 120 | 121 | private func synchronizeForegroundAttr() { 122 | navigationBarHelper.synchronizeForegroundAttr() 123 | } 124 | 125 | } 126 | -------------------------------------------------------------------------------- /NavigationBarHelper/Utilities.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Utilities.swift 3 | // 4 | // Copyright (c) 2015 Jerry Wong 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | import UIKit 25 | 26 | extension NSObject { 27 | 28 | class func exchange(_ oldSEL: Selector, withSEL newSEL: Selector) throws { 29 | 30 | guard let originMethod = class_getInstanceMethod(self, oldSEL), 31 | let altMethod = class_getInstanceMethod(self, newSEL) else { 32 | throw NSError(domain: "com.jerry", code: 0, userInfo: [NSLocalizedDescriptionKey: "cannot find methods for SEL \(oldSEL) or \(newSEL)"]) 33 | } 34 | 35 | let didAddMethod = class_addMethod(self, oldSEL, method_getImplementation(altMethod), method_getTypeEncoding(altMethod)) 36 | if didAddMethod { 37 | class_replaceMethod(self, newSEL, method_getImplementation(originMethod), method_getTypeEncoding(originMethod)) 38 | } else { 39 | method_exchangeImplementations(originMethod, altMethod) 40 | } 41 | } 42 | } 43 | 44 | extension UIImage { 45 | 46 | convenience init?(color: UIColor, size: CGSize? = CGSize(width: 1.0, height: 1.0)) { 47 | let rect = CGRect(origin: CGPoint.zero, size: size ?? CGSize(width: 1.0, height: 1.0)) 48 | 49 | UIGraphicsBeginImageContext(rect.size) 50 | defer { 51 | UIGraphicsEndImageContext() 52 | } 53 | 54 | let ctx = UIGraphicsGetCurrentContext() 55 | ctx?.setFillColor(color.cgColor) 56 | ctx?.fill(rect) 57 | guard let cgImage = UIGraphicsGetImageFromCurrentImageContext()?.cgImage else { 58 | return nil 59 | } 60 | self.init(cgImage: cgImage) 61 | } 62 | 63 | internal static let transparent = { UIImage(color: UIColor.clear)! }() 64 | 65 | } 66 | 67 | extension UIBarStyle { 68 | 69 | var shadowColor: UIColor { 70 | switch self { 71 | case .default: 72 | return UIColor(white: 0, alpha: 0.3) 73 | case .black, .blackTranslucent: 74 | return UIColor(white: 1.0, alpha: 0.15) 75 | @unknown default: 76 | return UIColor(white: 0, alpha: 0.3) 77 | } 78 | } 79 | 80 | var defaultBlurEffectConfig: (UIBlurEffect.Style, UIColor) { 81 | switch self { 82 | case .default: 83 | return (.light, UIColor(white: 0.97, alpha: 0.8)) 84 | case .black, .blackTranslucent: 85 | return (.dark, UIColor(white: 0.11, alpha: 0.73)) 86 | @unknown default: 87 | return (.light, UIColor(white: 0.97, alpha: 0.8)) 88 | } 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /NavigationBarHelperDemo/AccountViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AccountViewController.swift 3 | // NavigationBarTransitionHandler 4 | // 5 | // Created by Jerry Wong on 2018/3/8. 6 | // Copyright © 2018年 com.jerry. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import NavigationBarHelper 11 | 12 | class AccountViewController: UIViewController { 13 | 14 | @IBOutlet weak var collectionView: UICollectionView! 15 | 16 | @IBOutlet weak var flowLayout: UICollectionViewFlowLayout! 17 | 18 | let cellReuseIdentifiers = ["order", "member", "callCenter"] 19 | 20 | var barAlpha: CGFloat? { 21 | didSet { 22 | guard let alpha = barAlpha else { 23 | return 24 | } 25 | updateBarAlpha(alpha) 26 | } 27 | } 28 | 29 | override func viewDidLoad() { 30 | super.viewDidLoad() 31 | let itemWidth = (view.frame.size.width - 20 * 4) / 3.0 32 | flowLayout.itemSize = CGSize(width: itemWidth, height: itemWidth) 33 | navigationBarHelper.perform { 34 | $0.barStyle = .black 35 | $0.barTintColor = UIColor.orange 36 | $0.tintColor = UIColor.white 37 | } 38 | } 39 | 40 | override func didReceiveMemoryWarning() { 41 | super.didReceiveMemoryWarning() 42 | } 43 | 44 | func updateBarAlpha(_ val: CGFloat) { 45 | navigationController?.navigationBar.barStyle = val < 0.5 ? .default : .black 46 | navigationController?.navigationBar.tintColor = val < 0.2 ? UIColor.darkGray : UIColor.white 47 | navigationBarHelper.view?.alpha = val 48 | } 49 | } 50 | 51 | extension AccountViewController : NavigationBarHelperDelegate { 52 | 53 | func willRestore(backgroundAttr: inout NavigationBarHelper.BackgroundAttr) {} 54 | 55 | func didRestore(backgroundAttr: NavigationBarHelper.BackgroundAttr) {} 56 | 57 | func willRestore(foregroundAttr: inout NavigationBarHelper.ForegroundAttr) { 58 | if let val = barAlpha { 59 | foregroundAttr.barStyle = val < 0.5 ? .default : .black 60 | foregroundAttr.tintColor = val < 0.2 ? UIColor.darkGray : UIColor.white 61 | } 62 | } 63 | 64 | func didRestore(foregroundAttr: NavigationBarHelper.ForegroundAttr) { 65 | if let alpha = barAlpha { 66 | updateBarAlpha(alpha) 67 | } 68 | } 69 | } 70 | 71 | extension AccountViewController : UICollectionViewDelegate { 72 | 73 | func scrollViewDidScroll(_ scrollView: UIScrollView) { 74 | guard self.isViewLoaded, self.view.window != nil else { 75 | return 76 | } 77 | 78 | let offsetY = scrollView.contentOffset.y 79 | let topEdge = view.safeAreaInsets.top 80 | barAlpha = offsetY >= (CollectionHeaderHeight - topEdge) ? 1.0 : (offsetY < -topEdge ? 0 : (offsetY + topEdge) / CollectionHeaderHeight) 81 | } 82 | 83 | func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { 84 | if indexPath.item % 2 == 0 { 85 | self.performSegue(withIdentifier: "pushTimeline", sender: nil) 86 | } else if indexPath.item % 2 == 1 { 87 | navigationController?.popViewController(animated: true) 88 | } 89 | } 90 | 91 | } 92 | 93 | extension AccountViewController : UICollectionViewDataSource { 94 | 95 | func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 96 | return cellReuseIdentifiers.count * 6 97 | } 98 | 99 | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 100 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellReuseIdentifiers[indexPath.item % cellReuseIdentifiers.count], for: indexPath) 101 | return cell 102 | } 103 | 104 | func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { 105 | return collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "header", for: indexPath) 106 | } 107 | 108 | } 109 | 110 | private let CollectionHeaderHeight = CGFloat(110.0) 111 | -------------------------------------------------------------------------------- /NavigationBarHelperDemo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // NavigationBarTransitionHandler 4 | // 5 | // Created by Jerry Wong on 2018/2/28. 6 | // Copyright © 2018年 com.jerry. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import NavigationBarHelper 11 | 12 | @UIApplicationMain 13 | class AppDelegate: UIResponder, UIApplicationDelegate { 14 | 15 | var window: UIWindow? 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 18 | NavigationBarHelper.transitionStyle = .system 19 | NavigationBarHelperDemo.load() 20 | NavigationBarHelper.load() 21 | return true 22 | } 23 | 24 | func applicationWillResignActive(_ application: UIApplication) { 25 | // 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. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | func applicationDidEnterBackground(_ application: UIApplication) { 30 | // 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. 31 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 32 | } 33 | 34 | func applicationWillEnterForeground(_ application: UIApplication) { 35 | // 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. 36 | } 37 | 38 | func applicationDidBecomeActive(_ application: UIApplication) { 39 | // 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. 40 | } 41 | 42 | func applicationWillTerminate(_ application: UIApplication) { 43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 44 | } 45 | 46 | 47 | } 48 | 49 | -------------------------------------------------------------------------------- /NavigationBarHelperDemo/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 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /NavigationBarHelperDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /NavigationBarHelperDemo/Assets.xcassets/avatar.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "d443839ccaa5d102b747709c8864ad4c.jpeg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /NavigationBarHelperDemo/Assets.xcassets/avatar.imageset/d443839ccaa5d102b747709c8864ad4c.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jerry0523/NavigationBarHelper/767b5b7d4db6b79083b9e985605da74b03da53e4/NavigationBarHelperDemo/Assets.xcassets/avatar.imageset/d443839ccaa5d102b747709c8864ad4c.jpeg -------------------------------------------------------------------------------- /NavigationBarHelperDemo/Assets.xcassets/bar_background.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "DX-20180309@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /NavigationBarHelperDemo/Assets.xcassets/bar_background.imageset/DX-20180309@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jerry0523/NavigationBarHelper/767b5b7d4db6b79083b9e985605da74b03da53e4/NavigationBarHelperDemo/Assets.xcassets/bar_background.imageset/DX-20180309@2x.png -------------------------------------------------------------------------------- /NavigationBarHelperDemo/Assets.xcassets/star_sky.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "DX-20180308@2x.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /NavigationBarHelperDemo/Assets.xcassets/star_sky.imageset/DX-20180308@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jerry0523/NavigationBarHelper/767b5b7d4db6b79083b9e985605da74b03da53e4/NavigationBarHelperDemo/Assets.xcassets/star_sky.imageset/DX-20180308@2x.png -------------------------------------------------------------------------------- /NavigationBarHelperDemo/Assets.xcassets/timeline.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "timeline.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /NavigationBarHelperDemo/Assets.xcassets/timeline.imageset/timeline.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jerry0523/NavigationBarHelper/767b5b7d4db6b79083b9e985605da74b03da53e4/NavigationBarHelperDemo/Assets.xcassets/timeline.imageset/timeline.jpg -------------------------------------------------------------------------------- /NavigationBarHelperDemo/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 | -------------------------------------------------------------------------------- /NavigationBarHelperDemo/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 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 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 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 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 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 247 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 369 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | -------------------------------------------------------------------------------- /NavigationBarHelperDemo/HideNavigationBarViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HideNavigationBarViewController.swift 3 | // NavigationBarHelperDemo 4 | // 5 | // Created by 王杰 on 2018/12/28. 6 | // Copyright © 2018 com.jerry. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import NavigationBarHelper 11 | 12 | class HideNavigationBarViewController: UIViewController { 13 | 14 | override func viewDidLoad() { 15 | super.viewDidLoad() 16 | navigationBarHelper.perform { _ in 17 | self.navigationController?.setNavigationBarHidden(true, animated: true) 18 | } 19 | } 20 | 21 | @IBAction func didClickPopBtn(_ sender: UIButton) { 22 | navigationController?.popViewController(animated: true) 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /NavigationBarHelperDemo/HomeViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // NavigationBarTransitionHandlerDemo 4 | // 5 | // Created by Jerry Wong on 2018/2/28. 6 | // Copyright © 2018年 com.jerry. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import NavigationBarHelper 11 | 12 | class HomeViewController: UIViewController { 13 | 14 | override func viewDidLoad() { 15 | super.viewDidLoad() 16 | navigationBarHelper.perform { 17 | $0.barStyle = .black 18 | $0.tintColor = UIColor.white 19 | } 20 | } 21 | 22 | override func didReceiveMemoryWarning() { 23 | super.didReceiveMemoryWarning() 24 | } 25 | 26 | } 27 | 28 | -------------------------------------------------------------------------------- /NavigationBarHelperDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 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 | -------------------------------------------------------------------------------- /NavigationBarHelperDemo/ListViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ListViewController.swift 3 | // NavigationBarTransitionHandler 4 | // 5 | // Created by Jerry Wong on 2018/3/8. 6 | // Copyright © 2018年 com.jerry. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import NavigationBarHelper 11 | 12 | class ListViewController: UITableViewController { 13 | 14 | override func viewDidLoad() { 15 | super.viewDidLoad() 16 | navigationBarHelper.perform { 17 | $0.barStyle = .default 18 | $0.tintColor = UIColor.red 19 | } 20 | } 21 | 22 | override func didReceiveMemoryWarning() { 23 | super.didReceiveMemoryWarning() 24 | } 25 | 26 | override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 27 | tableView.deselectRow(at: indexPath, animated: true) 28 | switch indexPath.row { 29 | case 0: 30 | performSegue(withIdentifier: "pushAccount", sender: nil) 31 | case 1: 32 | navigationController?.popViewController(animated: true) 33 | default: 34 | break 35 | } 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /NavigationBarHelperDemo/SetViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SetViewController.swift 3 | // NavigationBarTransitionHandler 4 | // 5 | // Created by Jerry Wong on 2018/3/9. 6 | // Copyright © 2018年 com.jerry. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import NavigationBarHelper 11 | 12 | class SetViewController: UITableViewController { 13 | 14 | override func viewDidLoad() { 15 | super.viewDidLoad() 16 | navigationBarHelper.perform { 17 | $0.barStyle = .default 18 | $0.tintColor = UIColor.blue 19 | $0.setBackgroundImage(UIImage(named: "bar_background"), for: .default) 20 | } 21 | } 22 | 23 | override func didReceiveMemoryWarning() { 24 | super.didReceiveMemoryWarning() 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /NavigationBarHelperDemo/TimelineViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TimelineViewController.swift 3 | // NavigationBarHelperDemo 4 | // 5 | // Created by Jerry Wong on 2018/5/29. 6 | // Copyright © 2018年 com.jerry. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class TimelineViewController: UIViewController { 12 | 13 | let titleLabel = UILabel() 14 | 15 | let blanBarItem = UIBarButtonItem() 16 | 17 | var lastOffsetY: CGFloat? 18 | 19 | @IBOutlet weak var scrollView: UIScrollView! 20 | 21 | @IBOutlet var barRightItem: UIBarButtonItem! 22 | 23 | override func viewDidLoad() { 24 | super.viewDidLoad() 25 | navigationBarHelper.perform { 26 | $0.barStyle = .default 27 | $0.barTintColor = UIColor(red: 248.0 / 255.0, green: 229.0 / 255.0, blue: 213.0 / 255.0, alpha: 1.0) 28 | $0.tintColor = UIColor.purple 29 | } 30 | let barHeight = navigationBarHelper.view?.frame.height ?? 0 31 | titleLabel.frame = CGRect(x: 0, y: 20.0 + (barHeight - 20.0 - 20.0) * 0.5, width: view.frame.width, height: 20) 32 | titleLabel.autoresizingMask = [.flexibleWidth, .flexibleTopMargin, .flexibleBottomMargin] 33 | titleLabel.textAlignment = .center 34 | titleLabel.textColor = UIColor.purple 35 | titleLabel.font = UIFont.systemFont(ofSize: 12.0) 36 | navigationBarHelper.view?.addSubview(titleLabel) 37 | 38 | let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleTitleViewTap(_:))) 39 | navigationBarHelper.view?.addGestureRecognizer(tapGesture) 40 | } 41 | 42 | override func viewWillDisappear(_ animated: Bool) { 43 | super.viewWillDisappear(animated) 44 | expandNavigationBar(false) 45 | } 46 | 47 | override func didReceiveMemoryWarning() { 48 | super.didReceiveMemoryWarning() 49 | } 50 | 51 | @objc func handleTitleViewTap(_ sender: UITapGestureRecognizer) { 52 | expandNavigationBar(true) 53 | } 54 | } 55 | 56 | extension TimelineViewController: UIScrollViewDelegate { 57 | 58 | func scrollViewShouldScrollToTop(_ scrollView: UIScrollView) -> Bool { 59 | expandNavigationBar(true) 60 | return true 61 | } 62 | 63 | func scrollViewDidScroll(_ scrollView: UIScrollView) { 64 | let currentOffsetY = scrollView.contentOffset.y 65 | if scrollView.isTracking { 66 | if let lastOffsetY = lastOffsetY, lastOffsetY - currentOffsetY > 0 { 67 | expandNavigationBar(true) 68 | } else { 69 | if currentOffsetY <= -scrollView.contentInset.top - scrollView.adjustedContentInset.top { 70 | expandNavigationBar(true) 71 | } else { 72 | collapseNavigationBar(max(-currentOffsetY, 45)) 73 | } 74 | } 75 | } 76 | lastOffsetY = currentOffsetY 77 | } 78 | } 79 | 80 | extension TimelineViewController { 81 | 82 | func collapseNavigationBar(_ barHeight: CGFloat) { 83 | titleLabel.text = "Timeline" 84 | self.navigationItem.rightBarButtonItem = nil 85 | self.navigationItem.leftBarButtonItem = self.blanBarItem 86 | self.navigationBarHelper.view?.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: barHeight) 87 | } 88 | 89 | func expandNavigationBar(_ animated: Bool) { 90 | titleLabel.text = nil 91 | let insetsTop = max(view.safeAreaInsets.top, navigationController?.navigationBar.frame.size.height ?? 0) 92 | if navigationBarHelper.view?.bounds.height != insetsTop { 93 | 94 | func layoutNavigationBar() { 95 | self.navigationBarHelper.view?.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: insetsTop) 96 | } 97 | 98 | func resetNavigationItem() { 99 | self.navigationItem.rightBarButtonItem = self.barRightItem 100 | self.navigationItem.leftBarButtonItem = nil 101 | } 102 | if animated { 103 | UIView.animate(withDuration: 0.25, animations: { 104 | layoutNavigationBar() 105 | }) { (completed) in 106 | resetNavigationItem() 107 | } 108 | } else { 109 | layoutNavigationBar() 110 | resetNavigationItem() 111 | } 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.0 2 | 3 | import PackageDescription 4 | 5 | let package = Package( 6 | name: "NavigationBarHelper", 7 | platforms: [.iOS(.v10)], 8 | products: [ 9 | .library(name: "NavigationBarHelper", targets: ["NavigationBarHelper"]) 10 | ], 11 | targets: [ 12 | .target(name: "NavigationBarHelper", path: "NavigationBarHelper") 13 | ], 14 | swiftLanguageVersions: [.v5] 15 | ) 16 | -------------------------------------------------------------------------------- /PopInterrupter/UINavigationController+Swizzle.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UINavigationController+Swizzle.swift 3 | // 4 | // Copyright (c) 2015 Jerry Wong 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | import UIKit 25 | 26 | public func load() { 27 | _ = __init__ 28 | } 29 | 30 | private let __init__: Bool = { 31 | UINavigationController.exchange(#selector(UINavigationController.viewDidLoad), withSEL: #selector(UINavigationController.jw_viewDidLoad)) 32 | return true 33 | }() 34 | 35 | extension UINavigationController { 36 | 37 | @objc func jw_viewDidLoad() { 38 | jw_viewDidLoad() 39 | 40 | objc_setAssociatedObject(self, &UINavigationController.originDelegateKey, interactivePopGestureRecognizer?.delegate, .OBJC_ASSOCIATION_ASSIGN) 41 | interactivePopGestureRecognizer?.delegate = self 42 | } 43 | 44 | static var originDelegateKey: Void? 45 | } 46 | 47 | fileprivate extension NSObject { 48 | 49 | @discardableResult 50 | class func exchange(_ oldSEL: Selector, withSEL newSEL: Selector) -> Bool { 51 | 52 | guard let originMethod = class_getInstanceMethod(self, oldSEL), 53 | let altMethod = class_getInstanceMethod(self, newSEL) else { 54 | return false 55 | } 56 | 57 | let didAddMethod = class_addMethod(self, oldSEL, method_getImplementation(altMethod), method_getTypeEncoding(altMethod)) 58 | if didAddMethod { 59 | class_replaceMethod(self, newSEL, method_getImplementation(originMethod), method_getTypeEncoding(originMethod)) 60 | } else { 61 | method_exchangeImplementations(originMethod, altMethod) 62 | } 63 | return true 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /PopInterrupter/UIViewController+PopInterrupter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+PopHandler.swift 3 | // 4 | // Copyright (c) 2015 Jerry Wong 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | import UIKit 25 | 26 | public protocol AnyPopInterrupter { 27 | 28 | var isPopEnabled: Bool { get } 29 | 30 | } 31 | 32 | extension UINavigationController : UINavigationBarDelegate { 33 | 34 | public func navigationBar(_ navigationBar: UINavigationBar, shouldPop item: UINavigationItem) -> Bool { 35 | if viewControllers.count < navigationBar.items?.count ?? 0 { 36 | return true 37 | } 38 | var shouldPop = true 39 | if let vc = topViewController as? AnyPopInterrupter { 40 | shouldPop = vc.isPopEnabled 41 | } 42 | 43 | if shouldPop { 44 | DispatchQueue.main.async { 45 | self.popViewController(animated: true) 46 | } 47 | } else { 48 | UIView.animate(withDuration: 0.25, animations: { 49 | navigationBar.resetSubViewsAlpha() 50 | }) 51 | } 52 | return shouldPop 53 | } 54 | 55 | public func navigationBar(_ navigationBar: UINavigationBar, didPop item: UINavigationItem) { 56 | navigationBar.resetSubViewsAlpha() 57 | } 58 | } 59 | 60 | fileprivate extension UIView { 61 | 62 | func resetSubViewsAlpha() { 63 | subviews.forEach { (subView) in 64 | if subView.alpha != 1.0 { 65 | subView.alpha = 1.0 66 | } 67 | subView.resetSubViewsAlpha() 68 | } 69 | } 70 | } 71 | 72 | extension UINavigationController : UIGestureRecognizerDelegate { 73 | 74 | public func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool { 75 | if gestureRecognizer == interactivePopGestureRecognizer { 76 | if viewControllers.count <= 1 { 77 | return false 78 | } 79 | 80 | if let vc = topViewController as? AnyPopInterrupter { 81 | return vc.isPopEnabled 82 | } 83 | 84 | let originDelegate = objc_getAssociatedObject(self, &UINavigationController.originDelegateKey) as? UIGestureRecognizerDelegate 85 | return originDelegate?.gestureRecognizerShouldBegin?(gestureRecognizer) ?? true 86 | } 87 | return true 88 | } 89 | 90 | public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldBeRequiredToFailBy otherGestureRecognizer: UIGestureRecognizer) -> Bool { 91 | return gestureRecognizer == interactivePopGestureRecognizer 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/Jerry0523/NavigationBarHelper.svg?branch=master)](https://travis-ci.org/Jerry0523/NavigationBarHelper) 2 | # NavigationBarHelper 3 | A library that helps to manage the navigation bar style. It helps to remember bar attributes between different VCs and keep the transition smooth. 4 | 5 | ![alt tag](https://raw.githubusercontent.com/Jerry0523/NavigationBarHelper/master/screenshot.gif) 6 | 7 | 8 | Usage 9 | ------- 10 | 11 | ### When your app finishes launch, call the function below to start up the helper. 12 | 13 | ```swift 14 | NavigationBarHelper.load() 15 | ``` 16 | > swizzle UIViewController.viewSafeAreaInsetsDidChange 17 | 18 | > swizzle UIViewController.viewWillLayoutSubviews 19 | 20 | > swizzle UIViewController.viewWillAppear(_:) 21 | 22 | > UINavigationBar.hitTest(_:with:) 23 | 24 | ### For a viewController, use the function below to modify the navigation bar. 25 | 26 | ```swift 27 | override func viewDidLoad() { 28 | super.viewDidLoad() 29 | barBackgroundHelper.perform { 30 |        //Codes for navigation bar update. 31 | //e.g. $0.tintColor = UIColor.white 32 | } 33 | } 34 | ``` 35 | 36 | >After calling the function above, any attribute (background image/tintColor/barTintColor/barStyle etc) will be remembered by the library. It will create a mirror background view of the navigation bar (auto managed) and clear the bar background (to provide a smooth transition). Any change to the navigation bar background (background image/barTintColor/barStyle/shadowImage) in the closure will be syncronized with the mirror view. 37 | 38 | ### Protocol NavigationBarHelperDelegate 39 | 40 | - willRestore(backgroundAttr: inout NavigationBarHelper.BackgroundAttr) 41 | >Called before the mirror view capturing the bar's background attribute. Modify the backgroundAttr if it is not your appetite. 42 | 43 | - didRestore(backgroundAttr: NavigationBarHelper.BackgroundAttr) 44 | > Called after the mirror view capturing the bar's background attribute. It is the best time for you to do additional change to the bar's background attr. After this function is called, the mirror background view will synchronize with the bar's background. 45 | 46 | - willRestore(foregroundAttr: inout NavigationBarHelper.ForegroundAttr) 47 | > Called before the navigation bar's foreground attribute being restored, especially when the viewController's appearing. Modify the foregroundAttr if it is not your appetite. 48 | 49 | - didRestore(foregroundAttr: NavigationBarHelper.ForegroundAttr) 50 | > Called after the navigation bar's foreground attribute being restored, especially when the viewController's appearing. Do additional change if you have modified the navigation bar out of the performNavigationBarUpdates scope.(e.g, you have set the bar tint color according to scrollview offset). 51 | 52 | License 53 | ------- 54 | (MIT license) 55 | 56 | -------------------------------------------------------------------------------- /screenshot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jerry0523/NavigationBarHelper/767b5b7d4db6b79083b9e985605da74b03da53e4/screenshot.gif --------------------------------------------------------------------------------