├── README.md ├── 自定义导航控制器.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── Sekorm.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ ├── HelloYeah.xcuserdatad │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ │ ├── xcschememanagement.plist │ │ └── 自定义导航控制器.xcscheme │ └── Sekorm.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── xcschememanagement.plist │ └── 自定义导航控制器.xcscheme ├── 自定义导航控制器 ├── 1.jpg ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── 2.imageset │ │ └── 2.jpg │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── lol.imageset │ │ ├── Contents.json │ │ └── lol.jpg │ └── lol.jpg ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── HYNavBarHidden │ ├── HYViewController.h │ ├── HYViewController.m │ ├── UIViewController+NavBarHidden.h │ └── UIViewController+NavBarHidden.m ├── Info.plist ├── MyViewController.h ├── MyViewController.m ├── NavigationController.h ├── NavigationController.m ├── Objective-C.gitignore ├── TestCollectionController.h ├── TestCollectionController.m ├── TestViewController.h ├── TestViewController.m └── main.m ├── 自定义导航控制器Tests ├── Info.plist └── ________Tests.m └── 自定义导航控制器UITests ├── Info.plist └── ________UITests.m /README.md: -------------------------------------------------------------------------------- 1 | # HYNavBarHidden分类 2 | --- 3 | 4 | 超简单好用的监听滚动,导航条渐隐的UI效果实现(时下最流行的UI效果之一) 5 | 6 | 由于只有一个类文件,大家使用的时候直接拖进去去使用就好.笔者就不做cocoapods导入了. 7 | 8 | 使用过程中发现bug请先下载最新版,若bug依旧存在,请及时反馈,谢谢 9 | 10 | 11 | # HYNavBarHidden的优点<通过分类和继承两种方案实现,大家各凭喜好使用,继承方案源码较简单,可以先看继承方案,熟悉实现原理> 12 | --- 13 | 1.文件少,代码简洁,不依赖其他第三方库 14 | 15 | 2.接口简单,使用方便 16 | 17 | # HYNavBarHidden的使用 18 | --- 19 | 1.导入分类或者继承<通过分类和继承两种方案实现,大家各凭喜好使用> 20 | 21 | 2.使用方法,控制器实现接口方法 22 | 23 | -(void)setKeyScrollView:(UIScrollView * )keyScrollView scrolOffsetY:(CGFloat)scrolOffsetY options:(HYHidenControlOptions)options; 24 |   25 | 3.分类方案 26 | 27 | //分类方案 需要在相应的控制器里调用对应的方法 处理导航控制器push和pop操作 28 | - (void)hy_viewWillAppear:(BOOL)animated; 29 | - (void)hy_viewWillDisappear:(BOOL)animated; 30 | - (void)hy_viewDidDisappear:(BOOL)animated; 31 | 32 | # warning 33 | 34 | 由于导航控制器有push和pop操作,当有下级控制器时,则两个控制器共用一个导航条.侧滑时,导航条的效果有点瑕疵(边缘侧滑回上个控制器的时候,透明度有闪一下恢复的效果) 35 | 解决方案和思路(根据不同的需求自行选择) 36 | 37 | 1.当前控制器没有下级的控制器,即避免push操作了. 38 | 39 | 2.禁用手势侧滑.并在view的生命周期方法里面再进行调整恢复导航控制器的样式 40 | 41 | 3.pop出来的控制器中,隐藏导航条,用自定义的一个view充当导航条。这样可以完美的解决,并且不需要调用分类中 三个生命周期中的方法。(hy_viewWillAppear:, 42 | hy_viewWillDisappear,hy_viewDidDisappear:) 43 | # 效果演示 44 | --- 45 | ![1.gif](http://upload-images.jianshu.io/upload_images/1338042-b49f8c85cef44460.gif?imageMogr2/auto-orient/strip) 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /自定义导航控制器.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | B480A2FD1CCA1E4C00D2B972 /* HYViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B480A2FC1CCA1E4C00D2B972 /* HYViewController.m */; }; 11 | B480A3001CCA239A00D2B972 /* MyViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B480A2FF1CCA239A00D2B972 /* MyViewController.m */; }; 12 | B4D160341DF550AD0017C639 /* NavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = B4D160331DF550AD0017C639 /* NavigationController.m */; }; 13 | F801D39C1C93AF6300D14345 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F801D39B1C93AF6300D14345 /* main.m */; }; 14 | F801D39F1C93AF6300D14345 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F801D39E1C93AF6300D14345 /* AppDelegate.m */; }; 15 | F801D3A51C93AF6300D14345 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F801D3A31C93AF6300D14345 /* Main.storyboard */; }; 16 | F801D3A71C93AF6400D14345 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F801D3A61C93AF6400D14345 /* Assets.xcassets */; }; 17 | F801D3AA1C93AF6400D14345 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F801D3A81C93AF6400D14345 /* LaunchScreen.storyboard */; }; 18 | F801D3B51C93AF6400D14345 /* ________Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = F801D3B41C93AF6400D14345 /* ________Tests.m */; }; 19 | F801D3C01C93AF6400D14345 /* ________UITests.m in Sources */ = {isa = PBXBuildFile; fileRef = F801D3BF1C93AF6400D14345 /* ________UITests.m */; }; 20 | F8485AB31C93C18900A2158F /* TestViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F8485AB21C93C18900A2158F /* TestViewController.m */; }; 21 | F8485ABD1C93D06100A2158F /* UIViewController+NavBarHidden.m in Sources */ = {isa = PBXBuildFile; fileRef = F8485ABB1C93D06100A2158F /* UIViewController+NavBarHidden.m */; }; 22 | F8485AC01C93D3F400A2158F /* TestCollectionController.m in Sources */ = {isa = PBXBuildFile; fileRef = F8485ABF1C93D3F400A2158F /* TestCollectionController.m */; }; 23 | F8506FAB1C9482BD00B90DB1 /* 1.jpg in Resources */ = {isa = PBXBuildFile; fileRef = F8506FAA1C9482BD00B90DB1 /* 1.jpg */; }; 24 | F8B593CE1CB827D000DC7953 /* 2.jpg in Resources */ = {isa = PBXBuildFile; fileRef = F8B593CD1CB827D000DC7953 /* 2.jpg */; }; 25 | F8FC260F1C964006006878B3 /* Objective-C.gitignore in Resources */ = {isa = PBXBuildFile; fileRef = F8FC260E1C964006006878B3 /* Objective-C.gitignore */; }; 26 | /* End PBXBuildFile section */ 27 | 28 | /* Begin PBXContainerItemProxy section */ 29 | F801D3B11C93AF6400D14345 /* PBXContainerItemProxy */ = { 30 | isa = PBXContainerItemProxy; 31 | containerPortal = F801D38F1C93AF6300D14345 /* Project object */; 32 | proxyType = 1; 33 | remoteGlobalIDString = F801D3961C93AF6300D14345; 34 | remoteInfo = "自定义导航控制器"; 35 | }; 36 | F801D3BC1C93AF6400D14345 /* PBXContainerItemProxy */ = { 37 | isa = PBXContainerItemProxy; 38 | containerPortal = F801D38F1C93AF6300D14345 /* Project object */; 39 | proxyType = 1; 40 | remoteGlobalIDString = F801D3961C93AF6300D14345; 41 | remoteInfo = "自定义导航控制器"; 42 | }; 43 | /* End PBXContainerItemProxy section */ 44 | 45 | /* Begin PBXFileReference section */ 46 | B480A2FB1CCA1E4C00D2B972 /* HYViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HYViewController.h; sourceTree = ""; }; 47 | B480A2FC1CCA1E4C00D2B972 /* HYViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HYViewController.m; sourceTree = ""; }; 48 | B480A2FE1CCA239A00D2B972 /* MyViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MyViewController.h; sourceTree = ""; }; 49 | B480A2FF1CCA239A00D2B972 /* MyViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MyViewController.m; sourceTree = ""; }; 50 | B4D160321DF550AD0017C639 /* NavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavigationController.h; sourceTree = ""; }; 51 | B4D160331DF550AD0017C639 /* NavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NavigationController.m; sourceTree = ""; }; 52 | F801D3971C93AF6300D14345 /* 自定义导航控制器.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "自定义导航控制器.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | F801D39B1C93AF6300D14345 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 54 | F801D39D1C93AF6300D14345 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 55 | F801D39E1C93AF6300D14345 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 56 | F801D3A41C93AF6300D14345 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 57 | F801D3A61C93AF6400D14345 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 58 | F801D3A91C93AF6400D14345 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 59 | F801D3AB1C93AF6400D14345 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 60 | F801D3B01C93AF6400D14345 /* 自定义导航控制器Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "自定义导航控制器Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 61 | F801D3B41C93AF6400D14345 /* ________Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "________Tests.m"; sourceTree = ""; }; 62 | F801D3B61C93AF6400D14345 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 63 | F801D3BB1C93AF6400D14345 /* 自定义导航控制器UITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "自定义导航控制器UITests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 64 | F801D3BF1C93AF6400D14345 /* ________UITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "________UITests.m"; sourceTree = ""; }; 65 | F801D3C11C93AF6400D14345 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 66 | F8485AB11C93C18900A2158F /* TestViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestViewController.h; sourceTree = ""; }; 67 | F8485AB21C93C18900A2158F /* TestViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestViewController.m; sourceTree = ""; }; 68 | F8485ABA1C93D06100A2158F /* UIViewController+NavBarHidden.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+NavBarHidden.h"; sourceTree = ""; }; 69 | F8485ABB1C93D06100A2158F /* UIViewController+NavBarHidden.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+NavBarHidden.m"; sourceTree = ""; }; 70 | F8485ABE1C93D3F400A2158F /* TestCollectionController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestCollectionController.h; sourceTree = ""; }; 71 | F8485ABF1C93D3F400A2158F /* TestCollectionController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestCollectionController.m; sourceTree = ""; }; 72 | F8506FAA1C9482BD00B90DB1 /* 1.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 1.jpg; sourceTree = ""; }; 73 | F8B593CD1CB827D000DC7953 /* 2.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; name = 2.jpg; path = Assets.xcassets/2.imageset/2.jpg; sourceTree = ""; }; 74 | F8FC260E1C964006006878B3 /* Objective-C.gitignore */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "Objective-C.gitignore"; sourceTree = ""; }; 75 | /* End PBXFileReference section */ 76 | 77 | /* Begin PBXFrameworksBuildPhase section */ 78 | F801D3941C93AF6300D14345 /* Frameworks */ = { 79 | isa = PBXFrameworksBuildPhase; 80 | buildActionMask = 2147483647; 81 | files = ( 82 | ); 83 | runOnlyForDeploymentPostprocessing = 0; 84 | }; 85 | F801D3AD1C93AF6400D14345 /* Frameworks */ = { 86 | isa = PBXFrameworksBuildPhase; 87 | buildActionMask = 2147483647; 88 | files = ( 89 | ); 90 | runOnlyForDeploymentPostprocessing = 0; 91 | }; 92 | F801D3B81C93AF6400D14345 /* Frameworks */ = { 93 | isa = PBXFrameworksBuildPhase; 94 | buildActionMask = 2147483647; 95 | files = ( 96 | ); 97 | runOnlyForDeploymentPostprocessing = 0; 98 | }; 99 | /* End PBXFrameworksBuildPhase section */ 100 | 101 | /* Begin PBXGroup section */ 102 | F801D38E1C93AF6300D14345 = { 103 | isa = PBXGroup; 104 | children = ( 105 | F801D3991C93AF6300D14345 /* 自定义导航控制器 */, 106 | F801D3B31C93AF6400D14345 /* 自定义导航控制器Tests */, 107 | F801D3BE1C93AF6400D14345 /* 自定义导航控制器UITests */, 108 | F801D3981C93AF6300D14345 /* Products */, 109 | ); 110 | sourceTree = ""; 111 | }; 112 | F801D3981C93AF6300D14345 /* Products */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | F801D3971C93AF6300D14345 /* 自定义导航控制器.app */, 116 | F801D3B01C93AF6400D14345 /* 自定义导航控制器Tests.xctest */, 117 | F801D3BB1C93AF6400D14345 /* 自定义导航控制器UITests.xctest */, 118 | ); 119 | name = Products; 120 | sourceTree = ""; 121 | }; 122 | F801D3991C93AF6300D14345 /* 自定义导航控制器 */ = { 123 | isa = PBXGroup; 124 | children = ( 125 | F8485AB71C93D06100A2158F /* HYNavBarHidden */, 126 | F8485AB11C93C18900A2158F /* TestViewController.h */, 127 | F8485AB21C93C18900A2158F /* TestViewController.m */, 128 | F8485ABE1C93D3F400A2158F /* TestCollectionController.h */, 129 | F8485ABF1C93D3F400A2158F /* TestCollectionController.m */, 130 | B480A2FE1CCA239A00D2B972 /* MyViewController.h */, 131 | B480A2FF1CCA239A00D2B972 /* MyViewController.m */, 132 | B4D160321DF550AD0017C639 /* NavigationController.h */, 133 | B4D160331DF550AD0017C639 /* NavigationController.m */, 134 | F801D3A31C93AF6300D14345 /* Main.storyboard */, 135 | F801D3A61C93AF6400D14345 /* Assets.xcassets */, 136 | F8B593CD1CB827D000DC7953 /* 2.jpg */, 137 | F8506FAA1C9482BD00B90DB1 /* 1.jpg */, 138 | F801D3A81C93AF6400D14345 /* LaunchScreen.storyboard */, 139 | F801D3AB1C93AF6400D14345 /* Info.plist */, 140 | F801D39A1C93AF6300D14345 /* Supporting Files */, 141 | ); 142 | path = "自定义导航控制器"; 143 | sourceTree = ""; 144 | }; 145 | F801D39A1C93AF6300D14345 /* Supporting Files */ = { 146 | isa = PBXGroup; 147 | children = ( 148 | F8FC260E1C964006006878B3 /* Objective-C.gitignore */, 149 | F801D39D1C93AF6300D14345 /* AppDelegate.h */, 150 | F801D39E1C93AF6300D14345 /* AppDelegate.m */, 151 | F801D39B1C93AF6300D14345 /* main.m */, 152 | ); 153 | name = "Supporting Files"; 154 | sourceTree = ""; 155 | }; 156 | F801D3B31C93AF6400D14345 /* 自定义导航控制器Tests */ = { 157 | isa = PBXGroup; 158 | children = ( 159 | F801D3B41C93AF6400D14345 /* ________Tests.m */, 160 | F801D3B61C93AF6400D14345 /* Info.plist */, 161 | ); 162 | path = "自定义导航控制器Tests"; 163 | sourceTree = ""; 164 | }; 165 | F801D3BE1C93AF6400D14345 /* 自定义导航控制器UITests */ = { 166 | isa = PBXGroup; 167 | children = ( 168 | F801D3BF1C93AF6400D14345 /* ________UITests.m */, 169 | F801D3C11C93AF6400D14345 /* Info.plist */, 170 | ); 171 | path = "自定义导航控制器UITests"; 172 | sourceTree = ""; 173 | }; 174 | F8485AB71C93D06100A2158F /* HYNavBarHidden */ = { 175 | isa = PBXGroup; 176 | children = ( 177 | F8485ABA1C93D06100A2158F /* UIViewController+NavBarHidden.h */, 178 | F8485ABB1C93D06100A2158F /* UIViewController+NavBarHidden.m */, 179 | B480A2FB1CCA1E4C00D2B972 /* HYViewController.h */, 180 | B480A2FC1CCA1E4C00D2B972 /* HYViewController.m */, 181 | ); 182 | path = HYNavBarHidden; 183 | sourceTree = ""; 184 | }; 185 | /* End PBXGroup section */ 186 | 187 | /* Begin PBXNativeTarget section */ 188 | F801D3961C93AF6300D14345 /* 自定义导航控制器 */ = { 189 | isa = PBXNativeTarget; 190 | buildConfigurationList = F801D3C41C93AF6400D14345 /* Build configuration list for PBXNativeTarget "自定义导航控制器" */; 191 | buildPhases = ( 192 | F801D3931C93AF6300D14345 /* Sources */, 193 | F801D3941C93AF6300D14345 /* Frameworks */, 194 | F801D3951C93AF6300D14345 /* Resources */, 195 | ); 196 | buildRules = ( 197 | ); 198 | dependencies = ( 199 | ); 200 | name = "自定义导航控制器"; 201 | productName = "自定义导航控制器"; 202 | productReference = F801D3971C93AF6300D14345 /* 自定义导航控制器.app */; 203 | productType = "com.apple.product-type.application"; 204 | }; 205 | F801D3AF1C93AF6400D14345 /* 自定义导航控制器Tests */ = { 206 | isa = PBXNativeTarget; 207 | buildConfigurationList = F801D3C71C93AF6400D14345 /* Build configuration list for PBXNativeTarget "自定义导航控制器Tests" */; 208 | buildPhases = ( 209 | F801D3AC1C93AF6400D14345 /* Sources */, 210 | F801D3AD1C93AF6400D14345 /* Frameworks */, 211 | F801D3AE1C93AF6400D14345 /* Resources */, 212 | ); 213 | buildRules = ( 214 | ); 215 | dependencies = ( 216 | F801D3B21C93AF6400D14345 /* PBXTargetDependency */, 217 | ); 218 | name = "自定义导航控制器Tests"; 219 | productName = "自定义导航控制器Tests"; 220 | productReference = F801D3B01C93AF6400D14345 /* 自定义导航控制器Tests.xctest */; 221 | productType = "com.apple.product-type.bundle.unit-test"; 222 | }; 223 | F801D3BA1C93AF6400D14345 /* 自定义导航控制器UITests */ = { 224 | isa = PBXNativeTarget; 225 | buildConfigurationList = F801D3CA1C93AF6400D14345 /* Build configuration list for PBXNativeTarget "自定义导航控制器UITests" */; 226 | buildPhases = ( 227 | F801D3B71C93AF6400D14345 /* Sources */, 228 | F801D3B81C93AF6400D14345 /* Frameworks */, 229 | F801D3B91C93AF6400D14345 /* Resources */, 230 | ); 231 | buildRules = ( 232 | ); 233 | dependencies = ( 234 | F801D3BD1C93AF6400D14345 /* PBXTargetDependency */, 235 | ); 236 | name = "自定义导航控制器UITests"; 237 | productName = "自定义导航控制器UITests"; 238 | productReference = F801D3BB1C93AF6400D14345 /* 自定义导航控制器UITests.xctest */; 239 | productType = "com.apple.product-type.bundle.ui-testing"; 240 | }; 241 | /* End PBXNativeTarget section */ 242 | 243 | /* Begin PBXProject section */ 244 | F801D38F1C93AF6300D14345 /* Project object */ = { 245 | isa = PBXProject; 246 | attributes = { 247 | LastUpgradeCheck = 0720; 248 | ORGANIZATIONNAME = HelloYeah; 249 | TargetAttributes = { 250 | F801D3961C93AF6300D14345 = { 251 | CreatedOnToolsVersion = 7.2; 252 | DevelopmentTeam = W55448EFBF; 253 | }; 254 | F801D3AF1C93AF6400D14345 = { 255 | CreatedOnToolsVersion = 7.2; 256 | TestTargetID = F801D3961C93AF6300D14345; 257 | }; 258 | F801D3BA1C93AF6400D14345 = { 259 | CreatedOnToolsVersion = 7.2; 260 | TestTargetID = F801D3961C93AF6300D14345; 261 | }; 262 | }; 263 | }; 264 | buildConfigurationList = F801D3921C93AF6300D14345 /* Build configuration list for PBXProject "自定义导航控制器" */; 265 | compatibilityVersion = "Xcode 3.2"; 266 | developmentRegion = English; 267 | hasScannedForEncodings = 0; 268 | knownRegions = ( 269 | en, 270 | Base, 271 | ); 272 | mainGroup = F801D38E1C93AF6300D14345; 273 | productRefGroup = F801D3981C93AF6300D14345 /* Products */; 274 | projectDirPath = ""; 275 | projectRoot = ""; 276 | targets = ( 277 | F801D3961C93AF6300D14345 /* 自定义导航控制器 */, 278 | F801D3AF1C93AF6400D14345 /* 自定义导航控制器Tests */, 279 | F801D3BA1C93AF6400D14345 /* 自定义导航控制器UITests */, 280 | ); 281 | }; 282 | /* End PBXProject section */ 283 | 284 | /* Begin PBXResourcesBuildPhase section */ 285 | F801D3951C93AF6300D14345 /* Resources */ = { 286 | isa = PBXResourcesBuildPhase; 287 | buildActionMask = 2147483647; 288 | files = ( 289 | F8B593CE1CB827D000DC7953 /* 2.jpg in Resources */, 290 | F801D3AA1C93AF6400D14345 /* LaunchScreen.storyboard in Resources */, 291 | F8506FAB1C9482BD00B90DB1 /* 1.jpg in Resources */, 292 | F801D3A71C93AF6400D14345 /* Assets.xcassets in Resources */, 293 | F801D3A51C93AF6300D14345 /* Main.storyboard in Resources */, 294 | F8FC260F1C964006006878B3 /* Objective-C.gitignore in Resources */, 295 | ); 296 | runOnlyForDeploymentPostprocessing = 0; 297 | }; 298 | F801D3AE1C93AF6400D14345 /* Resources */ = { 299 | isa = PBXResourcesBuildPhase; 300 | buildActionMask = 2147483647; 301 | files = ( 302 | ); 303 | runOnlyForDeploymentPostprocessing = 0; 304 | }; 305 | F801D3B91C93AF6400D14345 /* Resources */ = { 306 | isa = PBXResourcesBuildPhase; 307 | buildActionMask = 2147483647; 308 | files = ( 309 | ); 310 | runOnlyForDeploymentPostprocessing = 0; 311 | }; 312 | /* End PBXResourcesBuildPhase section */ 313 | 314 | /* Begin PBXSourcesBuildPhase section */ 315 | F801D3931C93AF6300D14345 /* Sources */ = { 316 | isa = PBXSourcesBuildPhase; 317 | buildActionMask = 2147483647; 318 | files = ( 319 | F801D39F1C93AF6300D14345 /* AppDelegate.m in Sources */, 320 | F801D39C1C93AF6300D14345 /* main.m in Sources */, 321 | B480A3001CCA239A00D2B972 /* MyViewController.m in Sources */, 322 | F8485AC01C93D3F400A2158F /* TestCollectionController.m in Sources */, 323 | F8485AB31C93C18900A2158F /* TestViewController.m in Sources */, 324 | B4D160341DF550AD0017C639 /* NavigationController.m in Sources */, 325 | F8485ABD1C93D06100A2158F /* UIViewController+NavBarHidden.m in Sources */, 326 | B480A2FD1CCA1E4C00D2B972 /* HYViewController.m in Sources */, 327 | ); 328 | runOnlyForDeploymentPostprocessing = 0; 329 | }; 330 | F801D3AC1C93AF6400D14345 /* Sources */ = { 331 | isa = PBXSourcesBuildPhase; 332 | buildActionMask = 2147483647; 333 | files = ( 334 | F801D3B51C93AF6400D14345 /* ________Tests.m in Sources */, 335 | ); 336 | runOnlyForDeploymentPostprocessing = 0; 337 | }; 338 | F801D3B71C93AF6400D14345 /* Sources */ = { 339 | isa = PBXSourcesBuildPhase; 340 | buildActionMask = 2147483647; 341 | files = ( 342 | F801D3C01C93AF6400D14345 /* ________UITests.m in Sources */, 343 | ); 344 | runOnlyForDeploymentPostprocessing = 0; 345 | }; 346 | /* End PBXSourcesBuildPhase section */ 347 | 348 | /* Begin PBXTargetDependency section */ 349 | F801D3B21C93AF6400D14345 /* PBXTargetDependency */ = { 350 | isa = PBXTargetDependency; 351 | target = F801D3961C93AF6300D14345 /* 自定义导航控制器 */; 352 | targetProxy = F801D3B11C93AF6400D14345 /* PBXContainerItemProxy */; 353 | }; 354 | F801D3BD1C93AF6400D14345 /* PBXTargetDependency */ = { 355 | isa = PBXTargetDependency; 356 | target = F801D3961C93AF6300D14345 /* 自定义导航控制器 */; 357 | targetProxy = F801D3BC1C93AF6400D14345 /* PBXContainerItemProxy */; 358 | }; 359 | /* End PBXTargetDependency section */ 360 | 361 | /* Begin PBXVariantGroup section */ 362 | F801D3A31C93AF6300D14345 /* Main.storyboard */ = { 363 | isa = PBXVariantGroup; 364 | children = ( 365 | F801D3A41C93AF6300D14345 /* Base */, 366 | ); 367 | name = Main.storyboard; 368 | sourceTree = ""; 369 | }; 370 | F801D3A81C93AF6400D14345 /* LaunchScreen.storyboard */ = { 371 | isa = PBXVariantGroup; 372 | children = ( 373 | F801D3A91C93AF6400D14345 /* Base */, 374 | ); 375 | name = LaunchScreen.storyboard; 376 | sourceTree = ""; 377 | }; 378 | /* End PBXVariantGroup section */ 379 | 380 | /* Begin XCBuildConfiguration section */ 381 | F801D3C21C93AF6400D14345 /* Debug */ = { 382 | isa = XCBuildConfiguration; 383 | buildSettings = { 384 | ALWAYS_SEARCH_USER_PATHS = NO; 385 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 386 | CLANG_CXX_LIBRARY = "libc++"; 387 | CLANG_ENABLE_MODULES = YES; 388 | CLANG_ENABLE_OBJC_ARC = YES; 389 | CLANG_WARN_BOOL_CONVERSION = YES; 390 | CLANG_WARN_CONSTANT_CONVERSION = YES; 391 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 392 | CLANG_WARN_EMPTY_BODY = YES; 393 | CLANG_WARN_ENUM_CONVERSION = YES; 394 | CLANG_WARN_INT_CONVERSION = YES; 395 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 396 | CLANG_WARN_UNREACHABLE_CODE = YES; 397 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 398 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 399 | COPY_PHASE_STRIP = NO; 400 | DEBUG_INFORMATION_FORMAT = dwarf; 401 | ENABLE_STRICT_OBJC_MSGSEND = YES; 402 | ENABLE_TESTABILITY = YES; 403 | GCC_C_LANGUAGE_STANDARD = gnu99; 404 | GCC_DYNAMIC_NO_PIC = NO; 405 | GCC_NO_COMMON_BLOCKS = YES; 406 | GCC_OPTIMIZATION_LEVEL = 0; 407 | GCC_PREPROCESSOR_DEFINITIONS = ( 408 | "DEBUG=1", 409 | "$(inherited)", 410 | ); 411 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 412 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 413 | GCC_WARN_UNDECLARED_SELECTOR = YES; 414 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 415 | GCC_WARN_UNUSED_FUNCTION = YES; 416 | GCC_WARN_UNUSED_VARIABLE = YES; 417 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 418 | MTL_ENABLE_DEBUG_INFO = YES; 419 | ONLY_ACTIVE_ARCH = YES; 420 | SDKROOT = iphoneos; 421 | }; 422 | name = Debug; 423 | }; 424 | F801D3C31C93AF6400D14345 /* Release */ = { 425 | isa = XCBuildConfiguration; 426 | buildSettings = { 427 | ALWAYS_SEARCH_USER_PATHS = NO; 428 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 429 | CLANG_CXX_LIBRARY = "libc++"; 430 | CLANG_ENABLE_MODULES = YES; 431 | CLANG_ENABLE_OBJC_ARC = YES; 432 | CLANG_WARN_BOOL_CONVERSION = YES; 433 | CLANG_WARN_CONSTANT_CONVERSION = YES; 434 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 435 | CLANG_WARN_EMPTY_BODY = YES; 436 | CLANG_WARN_ENUM_CONVERSION = YES; 437 | CLANG_WARN_INT_CONVERSION = YES; 438 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 439 | CLANG_WARN_UNREACHABLE_CODE = YES; 440 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 441 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 442 | COPY_PHASE_STRIP = NO; 443 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 444 | ENABLE_NS_ASSERTIONS = NO; 445 | ENABLE_STRICT_OBJC_MSGSEND = YES; 446 | GCC_C_LANGUAGE_STANDARD = gnu99; 447 | GCC_NO_COMMON_BLOCKS = YES; 448 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 449 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 450 | GCC_WARN_UNDECLARED_SELECTOR = YES; 451 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 452 | GCC_WARN_UNUSED_FUNCTION = YES; 453 | GCC_WARN_UNUSED_VARIABLE = YES; 454 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 455 | MTL_ENABLE_DEBUG_INFO = NO; 456 | SDKROOT = iphoneos; 457 | VALIDATE_PRODUCT = YES; 458 | }; 459 | name = Release; 460 | }; 461 | F801D3C51C93AF6400D14345 /* Debug */ = { 462 | isa = XCBuildConfiguration; 463 | buildSettings = { 464 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 465 | CODE_SIGN_IDENTITY = "iPhone Developer"; 466 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 467 | INFOPLIST_FILE = "自定义导航控制器/Info.plist"; 468 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 469 | PRODUCT_BUNDLE_IDENTIFIER = yeliang.YLSetting; 470 | PRODUCT_NAME = "$(TARGET_NAME)"; 471 | PROVISIONING_PROFILE = ""; 472 | }; 473 | name = Debug; 474 | }; 475 | F801D3C61C93AF6400D14345 /* Release */ = { 476 | isa = XCBuildConfiguration; 477 | buildSettings = { 478 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 479 | CODE_SIGN_IDENTITY = "iPhone Developer"; 480 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 481 | INFOPLIST_FILE = "自定义导航控制器/Info.plist"; 482 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 483 | PRODUCT_BUNDLE_IDENTIFIER = yeliang.YLSetting; 484 | PRODUCT_NAME = "$(TARGET_NAME)"; 485 | PROVISIONING_PROFILE = ""; 486 | }; 487 | name = Release; 488 | }; 489 | F801D3C81C93AF6400D14345 /* Debug */ = { 490 | isa = XCBuildConfiguration; 491 | buildSettings = { 492 | BUNDLE_LOADER = "$(TEST_HOST)"; 493 | INFOPLIST_FILE = "自定义导航控制器Tests/Info.plist"; 494 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 495 | PRODUCT_BUNDLE_IDENTIFIER = "com.yeliang.--------Tests"; 496 | PRODUCT_NAME = "$(TARGET_NAME)"; 497 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/自定义导航控制器.app/自定义导航控制器"; 498 | }; 499 | name = Debug; 500 | }; 501 | F801D3C91C93AF6400D14345 /* Release */ = { 502 | isa = XCBuildConfiguration; 503 | buildSettings = { 504 | BUNDLE_LOADER = "$(TEST_HOST)"; 505 | INFOPLIST_FILE = "自定义导航控制器Tests/Info.plist"; 506 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 507 | PRODUCT_BUNDLE_IDENTIFIER = "com.yeliang.--------Tests"; 508 | PRODUCT_NAME = "$(TARGET_NAME)"; 509 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/自定义导航控制器.app/自定义导航控制器"; 510 | }; 511 | name = Release; 512 | }; 513 | F801D3CB1C93AF6400D14345 /* Debug */ = { 514 | isa = XCBuildConfiguration; 515 | buildSettings = { 516 | INFOPLIST_FILE = "自定义导航控制器UITests/Info.plist"; 517 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 518 | PRODUCT_BUNDLE_IDENTIFIER = "com.yeliang.--------UITests"; 519 | PRODUCT_NAME = "$(TARGET_NAME)"; 520 | TEST_TARGET_NAME = "自定义导航控制器"; 521 | USES_XCTRUNNER = YES; 522 | }; 523 | name = Debug; 524 | }; 525 | F801D3CC1C93AF6400D14345 /* Release */ = { 526 | isa = XCBuildConfiguration; 527 | buildSettings = { 528 | INFOPLIST_FILE = "自定义导航控制器UITests/Info.plist"; 529 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 530 | PRODUCT_BUNDLE_IDENTIFIER = "com.yeliang.--------UITests"; 531 | PRODUCT_NAME = "$(TARGET_NAME)"; 532 | TEST_TARGET_NAME = "自定义导航控制器"; 533 | USES_XCTRUNNER = YES; 534 | }; 535 | name = Release; 536 | }; 537 | /* End XCBuildConfiguration section */ 538 | 539 | /* Begin XCConfigurationList section */ 540 | F801D3921C93AF6300D14345 /* Build configuration list for PBXProject "自定义导航控制器" */ = { 541 | isa = XCConfigurationList; 542 | buildConfigurations = ( 543 | F801D3C21C93AF6400D14345 /* Debug */, 544 | F801D3C31C93AF6400D14345 /* Release */, 545 | ); 546 | defaultConfigurationIsVisible = 0; 547 | defaultConfigurationName = Release; 548 | }; 549 | F801D3C41C93AF6400D14345 /* Build configuration list for PBXNativeTarget "自定义导航控制器" */ = { 550 | isa = XCConfigurationList; 551 | buildConfigurations = ( 552 | F801D3C51C93AF6400D14345 /* Debug */, 553 | F801D3C61C93AF6400D14345 /* Release */, 554 | ); 555 | defaultConfigurationIsVisible = 0; 556 | defaultConfigurationName = Release; 557 | }; 558 | F801D3C71C93AF6400D14345 /* Build configuration list for PBXNativeTarget "自定义导航控制器Tests" */ = { 559 | isa = XCConfigurationList; 560 | buildConfigurations = ( 561 | F801D3C81C93AF6400D14345 /* Debug */, 562 | F801D3C91C93AF6400D14345 /* Release */, 563 | ); 564 | defaultConfigurationIsVisible = 0; 565 | defaultConfigurationName = Release; 566 | }; 567 | F801D3CA1C93AF6400D14345 /* Build configuration list for PBXNativeTarget "自定义导航控制器UITests" */ = { 568 | isa = XCConfigurationList; 569 | buildConfigurations = ( 570 | F801D3CB1C93AF6400D14345 /* Debug */, 571 | F801D3CC1C93AF6400D14345 /* Release */, 572 | ); 573 | defaultConfigurationIsVisible = 0; 574 | defaultConfigurationName = Release; 575 | }; 576 | /* End XCConfigurationList section */ 577 | }; 578 | rootObject = F801D38F1C93AF6300D14345 /* Project object */; 579 | } 580 | -------------------------------------------------------------------------------- /自定义导航控制器.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /自定义导航控制器.xcodeproj/project.xcworkspace/xcuserdata/Sekorm.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloYeah/HYNavBarHidden/2ac006d218ce5c6c04f0368d56b8f071603d5d82/自定义导航控制器.xcodeproj/project.xcworkspace/xcuserdata/Sekorm.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /自定义导航控制器.xcodeproj/xcuserdata/HelloYeah.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /自定义导航控制器.xcodeproj/xcuserdata/HelloYeah.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 自定义导航控制器.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | F801D3961C93AF6300D14345 16 | 17 | primary 18 | 19 | 20 | F801D3AF1C93AF6400D14345 21 | 22 | primary 23 | 24 | 25 | F801D3BA1C93AF6400D14345 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /自定义导航控制器.xcodeproj/xcuserdata/HelloYeah.xcuserdatad/xcschemes/自定义导航控制器.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /自定义导航控制器.xcodeproj/xcuserdata/Sekorm.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /自定义导航控制器.xcodeproj/xcuserdata/Sekorm.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 自定义导航控制器.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | F801D3961C93AF6300D14345 16 | 17 | primary 18 | 19 | 20 | F801D3AF1C93AF6400D14345 21 | 22 | primary 23 | 24 | 25 | F801D3BA1C93AF6400D14345 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /自定义导航控制器.xcodeproj/xcuserdata/Sekorm.xcuserdatad/xcschemes/自定义导航控制器.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /自定义导航控制器/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloYeah/HYNavBarHidden/2ac006d218ce5c6c04f0368d56b8f071603d5d82/自定义导航控制器/1.jpg -------------------------------------------------------------------------------- /自定义导航控制器/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 自定义导航控制器 4 | // 5 | // Created by HelloYeah on 16/3/12. 6 | // Copyright © 2016年 HelloYeah. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /自定义导航控制器/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // 自定义导航控制器 4 | // 5 | // Created by HelloYeah on 16/3/12. 6 | // Copyright © 2016年 HelloYeah. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // 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. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // 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. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /自定义导航控制器/Assets.xcassets/2.imageset/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloYeah/HYNavBarHidden/2ac006d218ce5c6c04f0368d56b8f071603d5d82/自定义导航控制器/Assets.xcassets/2.imageset/2.jpg -------------------------------------------------------------------------------- /自定义导航控制器/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /自定义导航控制器/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /自定义导航控制器/Assets.xcassets/lol.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "lol.jpg", 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 | } -------------------------------------------------------------------------------- /自定义导航控制器/Assets.xcassets/lol.imageset/lol.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloYeah/HYNavBarHidden/2ac006d218ce5c6c04f0368d56b8f071603d5d82/自定义导航控制器/Assets.xcassets/lol.imageset/lol.jpg -------------------------------------------------------------------------------- /自定义导航控制器/Assets.xcassets/lol.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelloYeah/HYNavBarHidden/2ac006d218ce5c6c04f0368d56b8f071603d5d82/自定义导航控制器/Assets.xcassets/lol.jpg -------------------------------------------------------------------------------- /自定义导航控制器/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /自定义导航控制器/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 | 47 | 48 | 49 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | 733 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 | 743 | 750 | 751 | 752 | 753 | 754 | 755 | 756 | 757 | 758 | 759 | 760 | 761 | 762 | 763 | 764 | 771 | 772 | 773 | 774 | 775 | 776 | 777 | 778 | 779 | 780 | 781 | 788 | 789 | 790 | 791 | 792 | 793 | 794 | 795 | 796 | 797 | 798 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 826 | 827 | 828 | 829 | 830 | 831 | 832 | 833 | 834 | 835 | 836 | 843 | 844 | 845 | 846 | 847 | 848 | 849 | 850 | 851 | 852 | 853 | 860 | 861 | 862 | 863 | 864 | 865 | 866 | 867 | 868 | 869 | 870 | 871 | 872 | 873 | 874 | 881 | 882 | 883 | 884 | 885 | 886 | 887 | 888 | 889 | 890 | 891 | 898 | 899 | 900 | 901 | 902 | 903 | 904 | 905 | 906 | 907 | 908 | 915 | 916 | 917 | 918 | 919 | 920 | 921 | 922 | 923 | 924 | 925 | 926 | 927 | 928 | 929 | 936 | 937 | 938 | 939 | 940 | 941 | 942 | 943 | 944 | 945 | 946 | 953 | 954 | 955 | 956 | 957 | 958 | 959 | 960 | 961 | 962 | 963 | 970 | 971 | 972 | 973 | 974 | 975 | 976 | 977 | 978 | 979 | 980 | 981 | 982 | 983 | 984 | 991 | 992 | 993 | 994 | 995 | 996 | 997 | 998 | 999 | 1000 | 1001 | 1008 | 1009 | 1010 | 1011 | 1012 | 1013 | 1014 | 1015 | 1016 | 1017 | 1018 | 1025 | 1026 | 1027 | 1028 | 1029 | 1030 | 1031 | 1032 | 1033 | 1034 | 1035 | 1036 | 1037 | 1038 | 1039 | 1046 | 1047 | 1048 | 1049 | 1050 | 1051 | 1052 | 1053 | 1054 | 1055 | 1056 | 1063 | 1064 | 1065 | 1066 | 1067 | 1068 | 1069 | 1070 | 1071 | 1072 | 1073 | 1080 | 1081 | 1082 | 1083 | 1084 | 1085 | 1086 | 1087 | 1088 | 1089 | 1090 | 1091 | 1092 | 1093 | 1094 | 1101 | 1102 | 1103 | 1104 | 1105 | 1106 | 1107 | 1108 | 1109 | 1110 | 1111 | 1118 | 1119 | 1120 | 1121 | 1122 | 1123 | 1124 | 1125 | 1126 | 1127 | 1128 | 1135 | 1136 | 1137 | 1138 | 1139 | 1140 | 1141 | 1142 | 1143 | 1144 | 1145 | 1146 | 1147 | 1148 | 1149 | 1150 | 1151 | 1152 | 1153 | 1154 | 1155 | 1156 | 1157 | 1158 | 1159 | 1160 | 1161 | 1162 | 1163 | 1164 | 1165 | 1166 | 1167 | 1168 | 1169 | 1170 | 1171 | 1172 | 1173 | 1174 | 1175 | 1176 | 1177 | 1178 | 1179 | 1180 | 1181 | 1182 | 1183 | 1184 | 1185 | 1186 | 1187 | 1188 | 1189 | 1190 | 1191 | 1192 | 1193 | 1194 | 1195 | 1196 | 1197 | 1198 | 1199 | 1200 | 1201 | 1202 | 1203 | 1204 | 1205 | 1206 | 1207 | 1208 | 1209 | 1210 | 1211 | 1212 | 1213 | 1214 | 1215 | 1216 | 1217 | 1218 | 1219 | 1220 | 1221 | 1222 | 1223 | 1224 | 1225 | 1226 | 1227 | 1228 | 1229 | 1230 | 1231 | 1232 | 1233 | 1234 | 1235 | 1236 | 1237 | 1238 | 1239 | 1240 | 1241 | 1242 | 1243 | 1244 | 1245 | 1246 | 1247 | 1248 | 1249 | 1250 | 1251 | 1252 | 1253 | 1254 | 1255 | 1256 | 1257 | 1258 | 1259 | 1260 | 1261 | 1262 | 1263 | 1264 | 1265 | 1266 | 1267 | 1268 | 1269 | 1270 | 1271 | 1272 | 1273 | 1274 | 1275 | 1276 | 1277 | 1278 | 1279 | 1280 | 1281 | 1282 | 1283 | 1284 | 1285 | 1286 | 1287 | 1288 | 1289 | 1290 | 1291 | 1292 | 1293 | 1294 | 1295 | 1296 | 1297 | 1298 | 1299 | 1300 | 1301 | 1302 | 1303 | 1304 | 1305 | 1306 | 1307 | 1308 | 1309 | 1310 | 1311 | 1312 | 1313 | 1314 | 1315 | 1316 | 1317 | 1318 | 1328 | 1329 | 1330 | 1331 | 1332 | 1333 | 1334 | 1335 | 1336 | 1337 | 1338 | 1339 | 1340 | 1341 | 1342 | 1343 | 1344 | 1345 | 1346 | 1347 | 1348 | 1349 | 1350 | 1351 | 1352 | 1353 | 1354 | 1355 | 1356 | 1357 | 1358 | 1359 | 1360 | -------------------------------------------------------------------------------- /自定义导航控制器/HYNavBarHidden/HYViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // HYViewController.h 3 | // 自定义导航控制器 4 | // 5 | // Created by Sekorm on 16/4/22. 6 | // Copyright © 2016年 HelloYeah. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef NS_OPTIONS(NSUInteger, HYHidenControlOptions) { 12 | 13 | HYHidenControlOptionLeft = 0x01, 14 | HYHidenControlOptionTitle = 0x01 << 1, 15 | HYHidenControlOptionRight = 0x01 << 2, 16 | 17 | }; 18 | 19 | @interface HYViewController : UIViewController 20 | 21 | - (void)setKeyScrollView:(UIScrollView * )keyScrollView scrolOffsetY:(CGFloat)scrolOffsetY options:(HYHidenControlOptions)options; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /自定义导航控制器/HYNavBarHidden/HYViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // HYViewController.m 3 | // 自定义导航控制器 4 | // 5 | // Created by Sekorm on 16/4/22. 6 | // Copyright © 2016年 HelloYeah. All rights reserved. 7 | // 8 | 9 | #import "HYViewController.h" 10 | 11 | @implementation HYViewController{ 12 | 13 | NSInteger _hidenControlOptions; 14 | CGFloat _scrolOffsetY; 15 | UIScrollView * _keyScrollView; 16 | CGFloat _alpha; 17 | UIImage * _navBarBackgroundImage; 18 | } 19 | 20 | - (void)setKeyScrollView:(UIScrollView * )keyScrollView scrolOffsetY:(CGFloat)scrolOffsetY options:(HYHidenControlOptions)options{ 21 | 22 | _keyScrollView = keyScrollView; 23 | _hidenControlOptions = options; 24 | _scrolOffsetY = scrolOffsetY; 25 | 26 | [_keyScrollView addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew context:nil]; 27 | } 28 | 29 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{ 30 | 31 | CGPoint point = _keyScrollView.contentOffset; 32 | _alpha = point.y/_scrolOffsetY; 33 | _alpha = (_alpha <= 0)?0:_alpha; 34 | _alpha = (_alpha >= 1)?1:_alpha; 35 | 36 | [self setNavSubViewsAlpha]; 37 | } 38 | 39 | - (void)dealloc{ 40 | 41 | [_keyScrollView removeObserver:self forKeyPath:@"contentOffset" context:nil]; 42 | } 43 | 44 | 45 | - (void)viewWillAppear:(BOOL)animated{ 46 | 47 | [super viewWillAppear:(BOOL)animated]; 48 | static dispatch_once_t onceToken; 49 | dispatch_once(&onceToken, ^{ 50 | 51 | _navBarBackgroundImage = [self.navigationController.navigationBar backgroundImageForBarMetrics:UIBarMetricsDefault]; 52 | }); 53 | 54 | 55 | //设置背景图片 56 | [self.navigationController.navigationBar setBackgroundImage:_navBarBackgroundImage forBarMetrics:UIBarMetricsDefault]; 57 | //清除边框,设置一张空的图片 58 | [self.navigationController.navigationBar setShadowImage:[[UIImage alloc]init]]; 59 | [self setNavSubViewsAlpha]; 60 | 61 | } 62 | 63 | - (void)viewDidAppear:(BOOL)animated { 64 | 65 | [super viewDidAppear:animated]; 66 | [self setNavSubViewsAlpha]; 67 | 68 | } 69 | 70 | - (void)viewWillDisappear:(BOOL)animated{ 71 | 72 | [super viewWillDisappear:animated]; 73 | [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault]; 74 | [self.navigationController.navigationBar setShadowImage:nil]; 75 | 76 | } 77 | 78 | - (void)viewDidDisappear:(BOOL)animated{ 79 | 80 | [super viewDidDisappear:animated]; 81 | [[[self.navigationController.navigationBar subviews] objectAtIndex:0] setAlpha:1]; 82 | 83 | } 84 | 85 | - (void)setNavSubViewsAlpha { 86 | 87 | self.navigationItem.leftBarButtonItem.customView.alpha = _hidenControlOptions & 1?_alpha:1; 88 | self.navigationItem.titleView.alpha = _hidenControlOptions >> 1 & 1 ?_alpha:1; 89 | self.navigationItem.rightBarButtonItem.customView.alpha = _hidenControlOptions >> 2 & 1?_alpha:1; 90 | [[[self.navigationController.navigationBar subviews]objectAtIndex:0] setAlpha:_alpha]; 91 | } 92 | 93 | @end 94 | -------------------------------------------------------------------------------- /自定义导航控制器/HYNavBarHidden/UIViewController+NavBarHidden.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+scrollerHidden.h 3 | // 自定义导航控制器 4 | // 5 | // Created by HelloYeah on 16/3/12. 6 | // Copyright © 2016年 HelloYeah--叶良. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | typedef NS_OPTIONS(NSUInteger, HYHidenControlOptions) { 13 | 14 | HYHidenControlOptionLeft = 0x01, 15 | HYHidenControlOptionTitle = 0x01 << 1, 16 | HYHidenControlOptionRight = 0x01 << 2, 17 | 18 | }; 19 | 20 | @interface UIViewController (NavBarHidden) 21 | 22 | - (void)setKeyScrollView:(UIScrollView * )keyScrollView scrolOffsetY:(CGFloat)scrolOffsetY options:(HYHidenControlOptions)options; 23 | - (void)setNavBarBackgroundImage:(UIImage *)navBarBackgroundImage; 24 | 25 | - (void)hy_viewWillAppear:(BOOL)animated; 26 | - (void)hy_viewWillDisappear:(BOOL)animated; 27 | - (void)hy_viewDidDisappear:(BOOL)animated; 28 | @end 29 | -------------------------------------------------------------------------------- /自定义导航控制器/HYNavBarHidden/UIViewController+NavBarHidden.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+scrollerHidden.m 3 | // 自定义导航控制器 4 | // 5 | // Created by HelloYeah on 16/3/12. 6 | // Copyright © 2016年 HelloYeah. All rights reserved. 7 | // 8 | 9 | #import "UIViewController+NavBarHidden.h" 10 | #import 11 | 12 | @interface UIViewController () 13 | @property (nonatomic,strong) UIImage * navBarBackgroundImage; //导航条的背景图片 14 | @property (nonatomic,weak) UIScrollView * keyScrollView;// 需要监听的view 15 | @property (nonatomic,assign) HYHidenControlOptions hy_hidenControlOptions;// 设置导航条上的标签是否需要跟随滚动变化透明度,默认不会跟随滚动变化透明度 16 | @property (nonatomic,assign) CGFloat scrolOffsetY;// ScrollView的Y轴偏移量大于scrolOffsetY的距离后,导航条的alpha为1 17 | @property (nonatomic,assign) CGFloat alpha; 18 | @end 19 | 20 | @implementation UIViewController (NavBarHidden) 21 | 22 | #pragma mark - ************* 通过运行时动态添加存储属性 ****************** 23 | //定义关联的Key 24 | static const char *key = "keyScrollView"; 25 | - (UIScrollView *)keyScrollView{ 26 | 27 | return objc_getAssociatedObject(self, key); 28 | } 29 | 30 | - (void)setKeyScrollView:(UIScrollView *)keyScrollView{ 31 | objc_setAssociatedObject(self, key, keyScrollView, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 32 | } 33 | 34 | //定义关联的Key 35 | static const char *navBarBackgroundImageKey = "navBarBackgroundImage"; 36 | - (UIImage *)navBarBackgroundImage{ 37 | return objc_getAssociatedObject(self, navBarBackgroundImageKey); 38 | } 39 | 40 | - (void)setNavBarBackgroundImage:(UIImage *)navBarBackgroundImage{ 41 | objc_setAssociatedObject(self, navBarBackgroundImageKey, navBarBackgroundImage, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 42 | } 43 | 44 | //定义关联的Key 45 | static const char *scrolOffsetYKey = "offsetY"; 46 | - (CGFloat)scrolOffsetY{ 47 | 48 | return [objc_getAssociatedObject(self, scrolOffsetYKey) floatValue]; 49 | } 50 | 51 | - (void)setScrolOffsetY:(CGFloat)scrolOffsetY{ 52 | 53 | objc_setAssociatedObject(self, scrolOffsetYKey, @(scrolOffsetY), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 54 | } 55 | 56 | //定义关联的Key 57 | static const char *alphaKey = "alpha"; 58 | - (CGFloat)alpha{ 59 | 60 | return [objc_getAssociatedObject(self, alphaKey) floatValue]; 61 | } 62 | 63 | - (void)setAlpha:(CGFloat)alpha{ 64 | 65 | objc_setAssociatedObject(self, alphaKey, @(alpha), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 66 | } 67 | 68 | //定义关联的Key 69 | static const char * hy_hidenControlOptionsKey = "hy_hidenControlOptions"; 70 | - (NSInteger)hy_hidenControlOptions{ 71 | 72 | return [objc_getAssociatedObject(self,hy_hidenControlOptionsKey) integerValue]; 73 | } 74 | - (void)setHy_hidenControlOptions:(NSInteger)hy_hidenControlOptions{ 75 | 76 | objc_setAssociatedObject(self, hy_hidenControlOptionsKey, @(hy_hidenControlOptions), OBJC_ASSOCIATION_ASSIGN); 77 | } 78 | 79 | #pragma mark - **************** 核心代码-对外接口功能实现代码 ****************** 80 | 81 | - (void)setKeyScrollView:(UIScrollView *)keyScrollView scrolOffsetY:(CGFloat)scrolOffsetY options:(HYHidenControlOptions)options{ 82 | 83 | self.keyScrollView = keyScrollView; 84 | self.hy_hidenControlOptions = options; 85 | self.scrolOffsetY = scrolOffsetY; 86 | [self.keyScrollView addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew context:nil]; 87 | } 88 | 89 | - (void)hy_viewWillAppear:(BOOL)animated { 90 | 91 | //设置背景图片 92 | [self.navigationController.navigationBar setBackgroundImage:self.navBarBackgroundImage forBarMetrics:UIBarMetricsDefault]; 93 | //清除边框,设置一张空的图片 94 | [self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]]; 95 | [self setNavSubViewsAlpha]; 96 | 97 | } 98 | 99 | - (void)hy_viewWillDisappear:(BOOL)animated { 100 | 101 | [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault]; 102 | [self.navigationController.navigationBar setShadowImage:nil]; 103 | 104 | } 105 | 106 | - (void)hy_viewDidDisappear:(BOOL)animated { 107 | 108 | [[[self.navigationController.navigationBar subviews]objectAtIndex:0] setAlpha:1]; 109 | } 110 | 111 | #pragma mark - *********************** 内部方法 ********************** 112 | 113 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{ 114 | 115 | CGFloat offsetY = self.scrolOffsetY; 116 | CGPoint point = self.keyScrollView.contentOffset; 117 | self.alpha = point.y/offsetY; 118 | self.alpha = (self.alpha <= 0)?0:self.alpha; 119 | self.alpha = (self.alpha >= 1)?1:self.alpha; 120 | [self setNavSubViewsAlpha]; 121 | 122 | } 123 | 124 | 125 | - (void)setNavSubViewsAlpha { 126 | 127 | self.navigationItem.leftBarButtonItem.customView.alpha = self.hy_hidenControlOptions & 1?self.alpha:1; 128 | self.navigationItem.titleView.alpha = self.hy_hidenControlOptions >> 1 & 1 ?self.alpha:1; 129 | self.navigationItem.rightBarButtonItem.customView.alpha = self.hy_hidenControlOptions >> 2 & 1?self.alpha:1; 130 | [[[self.navigationController.navigationBar subviews]objectAtIndex:0] setAlpha:self.alpha]; 131 | } 132 | 133 | @end 134 | -------------------------------------------------------------------------------- /自定义导航控制器/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | hidden 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UIRequiredDeviceCapabilities 32 | 33 | armv7 34 | 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationLandscapeLeft 39 | UIInterfaceOrientationLandscapeRight 40 | 41 | UIViewControllerBasedStatusBarAppearance 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /自定义导航控制器/MyViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MyViewController.h 3 | // 自定义导航控制器 4 | // 5 | // Created by Sekorm on 16/4/22. 6 | // Copyright © 2016年 HelloYeah. All rights reserved. 7 | // 8 | 9 | #import "HYViewController.h" 10 | 11 | @interface MyViewController : HYViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /自定义导航控制器/MyViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MyViewController.m 3 | // 自定义导航控制器 4 | // 5 | // Created by Sekorm on 16/4/22. 6 | // Copyright © 2016年 HelloYeah. All rights reserved. 7 | // 8 | 9 | #import "MyViewController.h" 10 | 11 | @interface MyViewController () 12 | 13 | @property (weak, nonatomic) IBOutlet UITableView *tableView; 14 | 15 | @end 16 | 17 | @implementation MyViewController 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | 22 | 23 | [self setKeyScrollView:self.tableView scrolOffsetY:600 options:HYHidenControlOptionLeft | HYHidenControlOptionTitle]; 24 | //设置背景图片 25 | [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"2.jpg"] forBarMetrics:UIBarMetricsDefault]; 26 | self.navigationItem.titleView = [UIButton buttonWithType:UIButtonTypeContactAdd]; 27 | self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:[UIButton buttonWithType:UIButtonTypeDetailDisclosure]]; 28 | self.tableView.rowHeight = 100; 29 | self.automaticallyAdjustsScrollViewInsets = NO; 30 | } 31 | 32 | 33 | 34 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 35 | 36 | return 100; 37 | } 38 | 39 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 40 | 41 | UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; 42 | if (!cell) { 43 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"]; 44 | 45 | } 46 | cell.backgroundColor = indexPath.row % 2 ? [UIColor orangeColor]:[UIColor greenColor]; 47 | 48 | cell.textLabel.text = @"zzzz"; 49 | return cell; 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /自定义导航控制器/NavigationController.h: -------------------------------------------------------------------------------- 1 | // 2 | // NavigationController.h 3 | // 自定义导航控制器 4 | // 5 | // Created by Sekorm on 2016/12/5. 6 | // Copyright © 2016年 HelloYeah. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NavigationController : UINavigationController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /自定义导航控制器/NavigationController.m: -------------------------------------------------------------------------------- 1 | // 2 | // NavigationController.m 3 | // 自定义导航控制器 4 | // 5 | // Created by Sekorm on 2016/12/5. 6 | // Copyright © 2016年 HelloYeah. All rights reserved. 7 | // 8 | 9 | #import "NavigationController.h" 10 | 11 | @implementation NavigationController 12 | 13 | - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated 14 | { 15 | if ([self.viewControllers count] > 0) { 16 | viewController.hidesBottomBarWhenPushed = YES; 17 | } 18 | [super pushViewController:viewController animated:animated]; 19 | } 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /自定义导航控制器/Objective-C.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 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | 28 | # CocoaPods 29 | # 30 | # We recommend against adding the Pods directory to your .gitignore. However 31 | # you should judge for yourself, the pros and cons are mentioned at: 32 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 33 | # 34 | # Pods/ 35 | 36 | # Carthage 37 | # 38 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 39 | # Carthage/Checkouts 40 | 41 | Carthage/Build 42 | 43 | # fastlane 44 | # 45 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 46 | # screenshots whenever they are needed. 47 | # For more information about the recommended setup visit: 48 | # https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md 49 | 50 | fastlane/report.xml 51 | fastlane/screenshots 52 | -------------------------------------------------------------------------------- /自定义导航控制器/TestCollectionController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TestCollectionController.h 3 | // 自定义导航控制器 4 | // 5 | // Created by HelloYeah on 16/3/12. 6 | // Copyright © 2016年 HelloYeah. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TestCollectionController : UIViewController 12 | 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /自定义导航控制器/TestCollectionController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TestCollectionController.m 3 | // 自定义导航控制器 4 | // 5 | // Created by HelloYeah on 16/3/12. 6 | // Copyright © 2016年 HelloYeah. All rights reserved. 7 | // 8 | 9 | #import "TestCollectionController.h" 10 | #import "UIViewController+NavBarHidden.h" 11 | 12 | @interface TestCollectionController () 13 | 14 | @property (nonatomic,weak) UICollectionView * collectionView; 15 | 16 | @end 17 | 18 | @implementation TestCollectionController 19 | 20 | -(void)viewDidLoad{ 21 | 22 | [super viewDidLoad]; 23 | 24 | //1.设置当有导航栏自动添加64的高度的属性为NO 25 | self.automaticallyAdjustsScrollViewInsets = NO; 26 | //2.设置导航条内容 27 | [self setUpNavBar]; 28 | [self setUpCollectionView]; 29 | [self setKeyScrollView:self.collectionView scrolOffsetY:600 options:HYHidenControlOptionTitle | HYHidenControlOptionLeft]; 30 | 31 | } 32 | 33 | - (void)viewDidDisappear:(BOOL)animated { 34 | 35 | [super viewDidDisappear:animated]; 36 | [self hy_viewDidDisappear:animated]; 37 | } 38 | 39 | - (void)viewWillAppear:(BOOL)animated { 40 | 41 | [super viewWillAppear:animated]; 42 | [self hy_viewWillAppear:animated]; 43 | } 44 | 45 | - (void)viewWillDisappear:(BOOL)animated { 46 | 47 | [super viewWillDisappear:animated]; 48 | [self hy_viewWillDisappear:animated]; 49 | } 50 | 51 | #pragma mark - UI设置 52 | 53 | - (void)setUpNavBar{ 54 | 55 | [self setNavBarBackgroundImage:[UIImage imageNamed:@"2.jpg"]]; 56 | UIButton * addBtn = [UIButton buttonWithType:UIButtonTypeContactAdd]; 57 | self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:addBtn]; 58 | UILabel * titleLabel =[[UILabel alloc]init]; 59 | titleLabel.text = @"HelloYeah"; 60 | [titleLabel sizeToFit]; 61 | titleLabel.textColor = [UIColor redColor]; 62 | self.navigationItem.titleView = titleLabel; 63 | } 64 | 65 | //初始化CollectionView 66 | - (void)setUpCollectionView{ 67 | 68 | //创建CollectionView 69 | UICollectionViewFlowLayout * layout = [[UICollectionViewFlowLayout alloc]init]; 70 | UICollectionView * collectionView = [[UICollectionView alloc]initWithFrame:self.view.bounds collectionViewLayout:layout];; 71 | //设置item属性 72 | layout.itemSize = CGSizeMake(self.view.bounds.size.width * 0.4, 200); 73 | layout.minimumInteritemSpacing = 20; 74 | layout.sectionInset = UIEdgeInsetsMake(270, 20, 20, 20); 75 | collectionView.backgroundColor = [UIColor whiteColor]; 76 | //添加到控制器上 77 | [self.view addSubview:collectionView]; 78 | self.collectionView = collectionView; 79 | [self setHeaderView]; 80 | collectionView.dataSource = self; 81 | //成为collectionView代理,监听滚动. 82 | collectionView.delegate = self; 83 | //注册cell 84 | [collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"test"]; 85 | 86 | } 87 | 88 | //设置头部视图 89 | - (void)setHeaderView{ 90 | 91 | NSString *filePath = [[NSBundle mainBundle] pathForResource:@"1.jpg" ofType:nil]; 92 | UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfFile:filePath]]; 93 | UIImageView * imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.collectionView.frame.size.width, 250)]; 94 | imageView.image = image; 95 | imageView.backgroundColor = [UIColor redColor]; 96 | [self.collectionView addSubview:imageView]; 97 | } 98 | 99 | 100 | #pragma mark - 数据源方法 101 | 102 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ 103 | 104 | return 20; 105 | } 106 | 107 | - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ 108 | 109 | UICollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"test" forIndexPath:indexPath]; 110 | cell.backgroundColor = [UIColor orangeColor]; 111 | return cell; 112 | } 113 | @end 114 | -------------------------------------------------------------------------------- /自定义导航控制器/TestViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TestViewController.h 3 | // 自定义导航控制器 4 | // 5 | // Created by HelloYeah on 16/3/12. 6 | // Copyright © 2016年 HelloYeah. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TestViewController : UITableViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /自定义导航控制器/TestViewController.m: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // TestViewController.m 4 | // 自定义导航控制器 5 | // 6 | // Created by HelloYeah on 16/3/12. 7 | // Copyright © 2016年 HelloYeah. All rights reserved. 8 | // 9 | 10 | #import "TestViewController.h" 11 | #import "UIViewController+NavBarHidden.h" 12 | 13 | @implementation TestViewController 14 | 15 | - (void)viewDidLoad{ 16 | 17 | [super viewDidLoad]; 18 | 19 | //设置当有导航栏自动添加64的高度的属性为NO 20 | self.automaticallyAdjustsScrollViewInsets = NO; 21 | 22 | [self setKeyScrollView:self.tableView scrolOffsetY:600 options:HYHidenControlOptionLeft | HYHidenControlOptionTitle]; 23 | //设置tableView的头部视图 24 | UIImageView * imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 0, 250)]; 25 | imageView.image = [UIImage imageNamed:@"lol"]; 26 | self.tableView.tableHeaderView = imageView; 27 | [self setNavBarBackgroundImage:[UIImage imageNamed:@"2.jpg"]]; 28 | 29 | } 30 | 31 | 32 | - (void)viewDidDisappear:(BOOL)animated { 33 | 34 | [super viewDidDisappear:animated]; 35 | [self hy_viewDidDisappear:animated]; 36 | } 37 | 38 | - (void)viewWillAppear:(BOOL)animated { 39 | 40 | [super viewWillAppear:animated]; 41 | [self hy_viewWillAppear:animated]; 42 | } 43 | 44 | - (void)viewWillDisappear:(BOOL)animated { 45 | 46 | [super viewWillDisappear:animated]; 47 | [self hy_viewWillDisappear:animated]; 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /自定义导航控制器/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 自定义导航控制器 4 | // 5 | // Created by HelloYeah on 16/3/12. 6 | // Copyright © 2016年 HelloYeah. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /自定义导航控制器Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /自定义导航控制器Tests/________Tests.m: -------------------------------------------------------------------------------- 1 | // 2 | // ________Tests.m 3 | // 自定义导航控制器Tests 4 | // 5 | // Created by HelloYeah on 16/3/12. 6 | // Copyright © 2016年 HelloYeah. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ________Tests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation ________Tests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /自定义导航控制器UITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /自定义导航控制器UITests/________UITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // ________UITests.m 3 | // 自定义导航控制器UITests 4 | // 5 | // Created by HelloYeah on 16/3/12. 6 | // Copyright © 2016年 HelloYeah. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ________UITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation ________UITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | --------------------------------------------------------------------------------