├── .gitignore ├── .travis.yml ├── Example ├── HLJNavigationBar.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── HLJNavigationBar-Example.xcscheme ├── HLJNavigationBar.xcworkspace │ └── contents.xcworkspacedata ├── HLJNavigationBar │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── HLJAddChildContainerViewController.h │ ├── HLJAddChildContainerViewController.m │ ├── HLJBackActionViewController.h │ ├── HLJBackActionViewController.m │ ├── HLJColorGradientViewController.h │ ├── HLJColorGradientViewController.m │ ├── HLJFixedSpaceTestViewController.h │ ├── HLJFixedSpaceTestViewController.m │ ├── HLJHiddenNavBarViewController.h │ ├── HLJHiddenNavBarViewController.m │ ├── HLJNavBarTitleViewController.h │ ├── HLJNavBarTitleViewController.m │ ├── HLJNavbarClearViewController.h │ ├── HLJNavbarClearViewController.m │ ├── HLJNavigationBar-Info.plist │ ├── HLJNavigationBar-Prefix.pch │ ├── HLJNavigationStackViewController.h │ ├── HLJNavigationStackViewController.m │ ├── HLJShadowImageViewController.h │ ├── HLJShadowImageViewController.m │ ├── HLJTestViewController.h │ ├── HLJTestViewController.m │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Contents.json │ │ ├── icon_common_back_main.imageset │ │ │ ├── Contents.json │ │ │ ├── thinBackIcon_red@2x.png │ │ │ └── thinBackIcon_red@3x.png │ │ ├── icon_common_message.imageset │ │ │ ├── Contents.json │ │ │ ├── icon_common_groupMessage@2x.png │ │ │ └── icon_common_groupMessage@3x.png │ │ └── image4.imageset │ │ │ ├── Contents.json │ │ │ └── image4.jpeg │ ├── en.lproj │ │ └── InfoPlist.strings │ ├── hljViewController.h │ ├── hljViewController.m │ └── main.m ├── Podfile └── Tests │ ├── Tests-Info.plist │ ├── Tests-Prefix.pch │ ├── Tests.m │ └── en.lproj │ └── InfoPlist.strings ├── HLJNavigationBar.podspec ├── HLJNavigationBar ├── Assets │ └── .gitkeep └── Classes │ ├── .gitkeep │ ├── ReplaceMe.m │ ├── UIBarButtonItem+HLJExtend.h │ ├── UIBarButtonItem+HLJExtend.m │ ├── UIColor+HLJNavBarExtend.h │ ├── UIColor+HLJNavBarExtend.m │ ├── UIGestureRecognizer+HLJNavBar.h │ ├── UIGestureRecognizer+HLJNavBar.m │ ├── UIImage+HLJNavBarExtend.h │ ├── UIImage+HLJNavBarExtend.m │ ├── UINavigationBar+HLJNavigationItem.h │ ├── UINavigationBar+HLJNavigationItem.m │ ├── UINavigationController+HLJNavBar.h │ ├── UINavigationController+HLJNavBar.m │ ├── UINavigationItem+HLJFixSpace.h │ ├── UINavigationItem+HLJFixSpace.m │ ├── UINavigationItem+HLJNavigationBar.h │ ├── UINavigationItem+HLJNavigationBar.m │ ├── UIStackView+HLJFixSpace.h │ ├── UIStackView+HLJFixSpace.m │ ├── UIView+HLJIntrinsicContentSize.h │ ├── UIView+HLJIntrinsicContentSize.m │ ├── UIViewController+HLJBackHandlerProtocol.h │ ├── UIViewController+HLJBackHandlerProtocol.m │ ├── UIViewController+HLJNavigationBar.h │ └── UIViewController+HLJNavigationBar.m ├── LICENSE ├── README.md └── _Pods.xcodeproj /.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 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | # CocoaPods 32 | # 33 | # We recommend against adding the Pods directory to your .gitignore. However 34 | # you should judge for yourself, the pros and cons are mentioned at: 35 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 36 | # 37 | # Pods/ 38 | 39 | # Carthage 40 | # 41 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 42 | # Carthage/Checkouts 43 | 44 | Carthage/Build 45 | 46 | # fastlane 47 | # 48 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 49 | # screenshots whenever they are needed. 50 | # For more information about the recommended setup visit: 51 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 52 | 53 | fastlane/report.xml 54 | fastlane/Preview.html 55 | fastlane/screenshots 56 | fastlane/test_output 57 | 58 | # Code Injection 59 | # 60 | # After new code Injection tools there's a generated folder /iOSInjectionProject 61 | # https://github.com/johnno1962/injectionforxcode 62 | 63 | iOSInjectionProject/ 64 | Example/Pods/* 65 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # references: 2 | # * http://www.objc.io/issue-6/travis-ci.html 3 | # * https://github.com/supermarin/xcpretty#usage 4 | 5 | osx_image: xcode7.3 6 | language: objective-c 7 | # cache: cocoapods 8 | # podfile: Example/Podfile 9 | # before_install: 10 | # - gem install cocoapods # Since Travis is not always on latest version 11 | # - pod install --project-directory=Example 12 | script: 13 | - set -o pipefail && xcodebuild test -enableCodeCoverage YES -workspace Example/HLJNavigationBar.xcworkspace -scheme HLJNavigationBar-Example -sdk iphonesimulator9.3 ONLY_ACTIVE_ARCH=NO | xcpretty 14 | - pod lib lint 15 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1165D4F8B5B6D396A2964962 /* libPods-HLJNavigationBar_Example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B2168145C88A119F4CB6CC3 /* libPods-HLJNavigationBar_Example.a */; }; 11 | 2781A1191F7BAF630016CAB1 /* HLJFixedSpaceTestViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2781A1181F7BAF620016CAB1 /* HLJFixedSpaceTestViewController.m */; }; 12 | 4C2EB8C91F5D24070031FFBF /* HLJBackActionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C2EB8C81F5D24070031FFBF /* HLJBackActionViewController.m */; }; 13 | 4C2EB8CC1F5D26160031FFBF /* HLJAddChildContainerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C2EB8CB1F5D26160031FFBF /* HLJAddChildContainerViewController.m */; }; 14 | 4C4C247D1F564543000309D9 /* HLJTestViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C4C247C1F564543000309D9 /* HLJTestViewController.m */; }; 15 | 4C4C24801F5647EC000309D9 /* HLJHiddenNavBarViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C4C247F1F5647EC000309D9 /* HLJHiddenNavBarViewController.m */; }; 16 | 4C4C24861F5656B0000309D9 /* HLJShadowImageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C4C24851F5656B0000309D9 /* HLJShadowImageViewController.m */; }; 17 | 4C4C24891F565792000309D9 /* HLJNavbarClearViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C4C24881F565792000309D9 /* HLJNavbarClearViewController.m */; }; 18 | 4C78DC1C1F7357EC00C084F0 /* HLJNavigationStackViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C78DC1B1F7357EC00C084F0 /* HLJNavigationStackViewController.m */; }; 19 | 4CC4A6961F568B12006F9E59 /* HLJNavBarTitleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC4A6951F568B12006F9E59 /* HLJNavBarTitleViewController.m */; }; 20 | 4CC4A6991F568BB7006F9E59 /* HLJColorGradientViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC4A6981F568BB7006F9E59 /* HLJColorGradientViewController.m */; }; 21 | 6003F58E195388D20070C39A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58D195388D20070C39A /* Foundation.framework */; }; 22 | 6003F590195388D20070C39A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58F195388D20070C39A /* CoreGraphics.framework */; }; 23 | 6003F592195388D20070C39A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; }; 24 | 6003F598195388D20070C39A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6003F596195388D20070C39A /* InfoPlist.strings */; }; 25 | 6003F59A195388D20070C39A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F599195388D20070C39A /* main.m */; }; 26 | 6003F59E195388D20070C39A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F59D195388D20070C39A /* AppDelegate.m */; }; 27 | 6003F5A7195388D20070C39A /* hljViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F5A6195388D20070C39A /* hljViewController.m */; }; 28 | 6003F5A9195388D20070C39A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6003F5A8195388D20070C39A /* Images.xcassets */; }; 29 | 6003F5B0195388D20070C39A /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F5AF195388D20070C39A /* XCTest.framework */; }; 30 | 6003F5B1195388D20070C39A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58D195388D20070C39A /* Foundation.framework */; }; 31 | 6003F5B2195388D20070C39A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; }; 32 | 6003F5BA195388D20070C39A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6003F5B8195388D20070C39A /* InfoPlist.strings */; }; 33 | 6003F5BC195388D20070C39A /* Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F5BB195388D20070C39A /* Tests.m */; }; 34 | 71719F9F1E33DC2100824A3D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 71719F9D1E33DC2100824A3D /* LaunchScreen.storyboard */; }; 35 | 873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */; }; 36 | /* End PBXBuildFile section */ 37 | 38 | /* Begin PBXContainerItemProxy section */ 39 | 6003F5B3195388D20070C39A /* PBXContainerItemProxy */ = { 40 | isa = PBXContainerItemProxy; 41 | containerPortal = 6003F582195388D10070C39A /* Project object */; 42 | proxyType = 1; 43 | remoteGlobalIDString = 6003F589195388D20070C39A; 44 | remoteInfo = HLJNavigationBar; 45 | }; 46 | /* End PBXContainerItemProxy section */ 47 | 48 | /* Begin PBXFileReference section */ 49 | 1B2168145C88A119F4CB6CC3 /* libPods-HLJNavigationBar_Example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-HLJNavigationBar_Example.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 50 | 2705769C1F79F4F1004AFB69 /* UINavigationItem+HLJFixSpace.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UINavigationItem+HLJFixSpace.m"; sourceTree = ""; }; 51 | 2705769D1F79F4F1004AFB69 /* UINavigationItem+HLJFixSpace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UINavigationItem+HLJFixSpace.h"; sourceTree = ""; }; 52 | 2781A1171F7BAF620016CAB1 /* HLJFixedSpaceTestViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HLJFixedSpaceTestViewController.h; sourceTree = ""; }; 53 | 2781A1181F7BAF620016CAB1 /* HLJFixedSpaceTestViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HLJFixedSpaceTestViewController.m; sourceTree = ""; }; 54 | 4C10D7301F556E5400F024D6 /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = ""; }; 55 | 4C10D7311F556E5400F024D6 /* ReplaceMe.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ReplaceMe.m; sourceTree = ""; }; 56 | 4C10D7321F556E7F00F024D6 /* UIViewController+HLJNavigationBar.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIViewController+HLJNavigationBar.h"; sourceTree = ""; }; 57 | 4C10D7331F556E7F00F024D6 /* UIViewController+HLJNavigationBar.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+HLJNavigationBar.m"; sourceTree = ""; }; 58 | 4C10D7351F55709400F024D6 /* UINavigationController+HLJNavBar.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UINavigationController+HLJNavBar.h"; sourceTree = ""; }; 59 | 4C10D7361F55709400F024D6 /* UINavigationController+HLJNavBar.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UINavigationController+HLJNavBar.m"; sourceTree = ""; }; 60 | 4C26BF191F7251D300521509 /* UINavigationItem+HLJNavigationBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UINavigationItem+HLJNavigationBar.h"; sourceTree = ""; }; 61 | 4C26BF1A1F7251D300521509 /* UINavigationItem+HLJNavigationBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UINavigationItem+HLJNavigationBar.m"; sourceTree = ""; }; 62 | 4C2EB8BB1F5CE7F20031FFBF /* UIColor+HLJNavBarExtend.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIColor+HLJNavBarExtend.h"; sourceTree = ""; }; 63 | 4C2EB8BC1F5CE7F20031FFBF /* UIColor+HLJNavBarExtend.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIColor+HLJNavBarExtend.m"; sourceTree = ""; }; 64 | 4C2EB8BE1F5CF2FB0031FFBF /* UIBarButtonItem+HLJExtend.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIBarButtonItem+HLJExtend.h"; sourceTree = ""; }; 65 | 4C2EB8BF1F5CF2FB0031FFBF /* UIBarButtonItem+HLJExtend.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIBarButtonItem+HLJExtend.m"; sourceTree = ""; }; 66 | 4C2EB8C41F5D1F2E0031FFBF /* UIGestureRecognizer+HLJNavBar.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIGestureRecognizer+HLJNavBar.h"; sourceTree = ""; }; 67 | 4C2EB8C51F5D1F2E0031FFBF /* UIGestureRecognizer+HLJNavBar.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIGestureRecognizer+HLJNavBar.m"; sourceTree = ""; }; 68 | 4C2EB8C71F5D24070031FFBF /* HLJBackActionViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HLJBackActionViewController.h; sourceTree = ""; }; 69 | 4C2EB8C81F5D24070031FFBF /* HLJBackActionViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HLJBackActionViewController.m; sourceTree = ""; }; 70 | 4C2EB8CA1F5D26160031FFBF /* HLJAddChildContainerViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HLJAddChildContainerViewController.h; sourceTree = ""; }; 71 | 4C2EB8CB1F5D26160031FFBF /* HLJAddChildContainerViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HLJAddChildContainerViewController.m; sourceTree = ""; }; 72 | 4C4C247B1F564543000309D9 /* HLJTestViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HLJTestViewController.h; sourceTree = ""; }; 73 | 4C4C247C1F564543000309D9 /* HLJTestViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HLJTestViewController.m; sourceTree = ""; }; 74 | 4C4C247E1F5647EC000309D9 /* HLJHiddenNavBarViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HLJHiddenNavBarViewController.h; sourceTree = ""; }; 75 | 4C4C247F1F5647EC000309D9 /* HLJHiddenNavBarViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HLJHiddenNavBarViewController.m; sourceTree = ""; }; 76 | 4C4C24811F564FA2000309D9 /* UIImage+HLJNavBarExtend.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIImage+HLJNavBarExtend.h"; sourceTree = ""; }; 77 | 4C4C24821F564FA2000309D9 /* UIImage+HLJNavBarExtend.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIImage+HLJNavBarExtend.m"; sourceTree = ""; }; 78 | 4C4C24841F5656B0000309D9 /* HLJShadowImageViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HLJShadowImageViewController.h; sourceTree = ""; }; 79 | 4C4C24851F5656B0000309D9 /* HLJShadowImageViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HLJShadowImageViewController.m; sourceTree = ""; }; 80 | 4C4C24871F565792000309D9 /* HLJNavbarClearViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HLJNavbarClearViewController.h; sourceTree = ""; }; 81 | 4C4C24881F565792000309D9 /* HLJNavbarClearViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HLJNavbarClearViewController.m; sourceTree = ""; }; 82 | 4C78DC1A1F7357EC00C084F0 /* HLJNavigationStackViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HLJNavigationStackViewController.h; sourceTree = ""; }; 83 | 4C78DC1B1F7357EC00C084F0 /* HLJNavigationStackViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HLJNavigationStackViewController.m; sourceTree = ""; }; 84 | 4C78DC201F73B2A800C084F0 /* UIView+HLJIntrinsicContentSize.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIView+HLJIntrinsicContentSize.m"; sourceTree = ""; }; 85 | 4C78DC211F73B2A800C084F0 /* UIView+HLJIntrinsicContentSize.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIView+HLJIntrinsicContentSize.h"; sourceTree = ""; }; 86 | 4CC4A6941F568B12006F9E59 /* HLJNavBarTitleViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HLJNavBarTitleViewController.h; sourceTree = ""; }; 87 | 4CC4A6951F568B12006F9E59 /* HLJNavBarTitleViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HLJNavBarTitleViewController.m; sourceTree = ""; }; 88 | 4CC4A6971F568BB7006F9E59 /* HLJColorGradientViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HLJColorGradientViewController.h; sourceTree = ""; }; 89 | 4CC4A6981F568BB7006F9E59 /* HLJColorGradientViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HLJColorGradientViewController.m; sourceTree = ""; }; 90 | 4CC4A6C21F56B4D3006F9E59 /* UINavigationBar+HLJNavigationItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UINavigationBar+HLJNavigationItem.h"; sourceTree = ""; }; 91 | 4CC4A6C31F56B4D3006F9E59 /* UINavigationBar+HLJNavigationItem.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UINavigationBar+HLJNavigationItem.m"; sourceTree = ""; }; 92 | 4CC4A6C51F56BB5B006F9E59 /* UIViewController+HLJBackHandlerProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIViewController+HLJBackHandlerProtocol.h"; sourceTree = ""; }; 93 | 4CC4A6C61F56BB5B006F9E59 /* UIViewController+HLJBackHandlerProtocol.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+HLJBackHandlerProtocol.m"; sourceTree = ""; }; 94 | 6003F58A195388D20070C39A /* HLJNavigationBar_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HLJNavigationBar_Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 95 | 6003F58D195388D20070C39A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 96 | 6003F58F195388D20070C39A /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 97 | 6003F591195388D20070C39A /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 98 | 6003F595195388D20070C39A /* HLJNavigationBar-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "HLJNavigationBar-Info.plist"; sourceTree = ""; }; 99 | 6003F597195388D20070C39A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 100 | 6003F599195388D20070C39A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 101 | 6003F59B195388D20070C39A /* HLJNavigationBar-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "HLJNavigationBar-Prefix.pch"; sourceTree = ""; }; 102 | 6003F59C195388D20070C39A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 103 | 6003F59D195388D20070C39A /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 104 | 6003F5A5195388D20070C39A /* hljViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = hljViewController.h; sourceTree = ""; }; 105 | 6003F5A6195388D20070C39A /* hljViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = hljViewController.m; sourceTree = ""; }; 106 | 6003F5A8195388D20070C39A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 107 | 6003F5AE195388D20070C39A /* HLJNavigationBar_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = HLJNavigationBar_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 108 | 6003F5AF195388D20070C39A /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 109 | 6003F5B7195388D20070C39A /* Tests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Tests-Info.plist"; sourceTree = ""; }; 110 | 6003F5B9195388D20070C39A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 111 | 6003F5BB195388D20070C39A /* Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Tests.m; sourceTree = ""; }; 112 | 606FC2411953D9B200FFA9A0 /* Tests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Tests-Prefix.pch"; sourceTree = ""; }; 113 | 70B572EC6308951921A6EDFC /* HLJNavigationBar.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = HLJNavigationBar.podspec; path = ../HLJNavigationBar.podspec; sourceTree = ""; }; 114 | 71719F9E1E33DC2100824A3D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 115 | 7270D1AA9D9BED50734E01E1 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; 116 | 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = Main.storyboard; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 117 | 889A507865748C7A9B3460DC /* Pods-HLJNavigationBar_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HLJNavigationBar_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-HLJNavigationBar_Example/Pods-HLJNavigationBar_Example.release.xcconfig"; sourceTree = ""; }; 118 | 89A6DA0CE0A9A1FA3F97EE12 /* Pods_HLJNavigationBar_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_HLJNavigationBar_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 119 | AFC1245B22D10E5FC733AD4A /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; 120 | F55E343F8249BD0C392707D3 /* Pods-HLJNavigationBar_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HLJNavigationBar_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-HLJNavigationBar_Example/Pods-HLJNavigationBar_Example.debug.xcconfig"; sourceTree = ""; }; 121 | /* End PBXFileReference section */ 122 | 123 | /* Begin PBXFrameworksBuildPhase section */ 124 | 6003F587195388D20070C39A /* Frameworks */ = { 125 | isa = PBXFrameworksBuildPhase; 126 | buildActionMask = 2147483647; 127 | files = ( 128 | 6003F590195388D20070C39A /* CoreGraphics.framework in Frameworks */, 129 | 6003F592195388D20070C39A /* UIKit.framework in Frameworks */, 130 | 6003F58E195388D20070C39A /* Foundation.framework in Frameworks */, 131 | 1165D4F8B5B6D396A2964962 /* libPods-HLJNavigationBar_Example.a in Frameworks */, 132 | ); 133 | runOnlyForDeploymentPostprocessing = 0; 134 | }; 135 | 6003F5AB195388D20070C39A /* Frameworks */ = { 136 | isa = PBXFrameworksBuildPhase; 137 | buildActionMask = 2147483647; 138 | files = ( 139 | 6003F5B0195388D20070C39A /* XCTest.framework in Frameworks */, 140 | 6003F5B2195388D20070C39A /* UIKit.framework in Frameworks */, 141 | 6003F5B1195388D20070C39A /* Foundation.framework in Frameworks */, 142 | ); 143 | runOnlyForDeploymentPostprocessing = 0; 144 | }; 145 | /* End PBXFrameworksBuildPhase section */ 146 | 147 | /* Begin PBXGroup section */ 148 | 4C10D72F1F556E5400F024D6 /* Classes */ = { 149 | isa = PBXGroup; 150 | children = ( 151 | 2705769D1F79F4F1004AFB69 /* UINavigationItem+HLJFixSpace.h */, 152 | 2705769C1F79F4F1004AFB69 /* UINavigationItem+HLJFixSpace.m */, 153 | 4C10D7301F556E5400F024D6 /* .gitkeep */, 154 | 4C10D7311F556E5400F024D6 /* ReplaceMe.m */, 155 | 4C10D7321F556E7F00F024D6 /* UIViewController+HLJNavigationBar.h */, 156 | 4C10D7331F556E7F00F024D6 /* UIViewController+HLJNavigationBar.m */, 157 | 4C10D7351F55709400F024D6 /* UINavigationController+HLJNavBar.h */, 158 | 4C10D7361F55709400F024D6 /* UINavigationController+HLJNavBar.m */, 159 | 4C2EB8C41F5D1F2E0031FFBF /* UIGestureRecognizer+HLJNavBar.h */, 160 | 4C2EB8C51F5D1F2E0031FFBF /* UIGestureRecognizer+HLJNavBar.m */, 161 | 4C4C24811F564FA2000309D9 /* UIImage+HLJNavBarExtend.h */, 162 | 4C4C24821F564FA2000309D9 /* UIImage+HLJNavBarExtend.m */, 163 | 4C2EB8BB1F5CE7F20031FFBF /* UIColor+HLJNavBarExtend.h */, 164 | 4C2EB8BC1F5CE7F20031FFBF /* UIColor+HLJNavBarExtend.m */, 165 | 4CC4A6C21F56B4D3006F9E59 /* UINavigationBar+HLJNavigationItem.h */, 166 | 4CC4A6C31F56B4D3006F9E59 /* UINavigationBar+HLJNavigationItem.m */, 167 | 4CC4A6C51F56BB5B006F9E59 /* UIViewController+HLJBackHandlerProtocol.h */, 168 | 4CC4A6C61F56BB5B006F9E59 /* UIViewController+HLJBackHandlerProtocol.m */, 169 | 4C2EB8BE1F5CF2FB0031FFBF /* UIBarButtonItem+HLJExtend.h */, 170 | 4C2EB8BF1F5CF2FB0031FFBF /* UIBarButtonItem+HLJExtend.m */, 171 | 4C26BF191F7251D300521509 /* UINavigationItem+HLJNavigationBar.h */, 172 | 4C26BF1A1F7251D300521509 /* UINavigationItem+HLJNavigationBar.m */, 173 | 4C78DC211F73B2A800C084F0 /* UIView+HLJIntrinsicContentSize.h */, 174 | 4C78DC201F73B2A800C084F0 /* UIView+HLJIntrinsicContentSize.m */, 175 | ); 176 | name = Classes; 177 | path = ../HLJNavigationBar/Classes; 178 | sourceTree = ""; 179 | }; 180 | 6003F581195388D10070C39A = { 181 | isa = PBXGroup; 182 | children = ( 183 | 4C10D72F1F556E5400F024D6 /* Classes */, 184 | 60FF7A9C1954A5C5007DD14C /* Podspec Metadata */, 185 | 6003F593195388D20070C39A /* Example for HLJNavigationBar */, 186 | 6003F5B5195388D20070C39A /* Tests */, 187 | 6003F58C195388D20070C39A /* Frameworks */, 188 | 6003F58B195388D20070C39A /* Products */, 189 | 8DFEA5B1063AD41DF1B8EA69 /* Pods */, 190 | ); 191 | sourceTree = ""; 192 | }; 193 | 6003F58B195388D20070C39A /* Products */ = { 194 | isa = PBXGroup; 195 | children = ( 196 | 6003F58A195388D20070C39A /* HLJNavigationBar_Example.app */, 197 | 6003F5AE195388D20070C39A /* HLJNavigationBar_Tests.xctest */, 198 | ); 199 | name = Products; 200 | sourceTree = ""; 201 | }; 202 | 6003F58C195388D20070C39A /* Frameworks */ = { 203 | isa = PBXGroup; 204 | children = ( 205 | 6003F58D195388D20070C39A /* Foundation.framework */, 206 | 6003F58F195388D20070C39A /* CoreGraphics.framework */, 207 | 6003F591195388D20070C39A /* UIKit.framework */, 208 | 6003F5AF195388D20070C39A /* XCTest.framework */, 209 | 89A6DA0CE0A9A1FA3F97EE12 /* Pods_HLJNavigationBar_Tests.framework */, 210 | 1B2168145C88A119F4CB6CC3 /* libPods-HLJNavigationBar_Example.a */, 211 | ); 212 | name = Frameworks; 213 | sourceTree = ""; 214 | }; 215 | 6003F593195388D20070C39A /* Example for HLJNavigationBar */ = { 216 | isa = PBXGroup; 217 | children = ( 218 | 2781A1171F7BAF620016CAB1 /* HLJFixedSpaceTestViewController.h */, 219 | 2781A1181F7BAF620016CAB1 /* HLJFixedSpaceTestViewController.m */, 220 | 6003F59C195388D20070C39A /* AppDelegate.h */, 221 | 6003F59D195388D20070C39A /* AppDelegate.m */, 222 | 4C4C247B1F564543000309D9 /* HLJTestViewController.h */, 223 | 4C4C247C1F564543000309D9 /* HLJTestViewController.m */, 224 | 4C4C247E1F5647EC000309D9 /* HLJHiddenNavBarViewController.h */, 225 | 4C4C247F1F5647EC000309D9 /* HLJHiddenNavBarViewController.m */, 226 | 4C4C24841F5656B0000309D9 /* HLJShadowImageViewController.h */, 227 | 4C4C24851F5656B0000309D9 /* HLJShadowImageViewController.m */, 228 | 4C4C24871F565792000309D9 /* HLJNavbarClearViewController.h */, 229 | 4C4C24881F565792000309D9 /* HLJNavbarClearViewController.m */, 230 | 4CC4A6941F568B12006F9E59 /* HLJNavBarTitleViewController.h */, 231 | 4CC4A6951F568B12006F9E59 /* HLJNavBarTitleViewController.m */, 232 | 4CC4A6971F568BB7006F9E59 /* HLJColorGradientViewController.h */, 233 | 4CC4A6981F568BB7006F9E59 /* HLJColorGradientViewController.m */, 234 | 4C2EB8C71F5D24070031FFBF /* HLJBackActionViewController.h */, 235 | 4C2EB8C81F5D24070031FFBF /* HLJBackActionViewController.m */, 236 | 4C2EB8CA1F5D26160031FFBF /* HLJAddChildContainerViewController.h */, 237 | 4C2EB8CB1F5D26160031FFBF /* HLJAddChildContainerViewController.m */, 238 | 4C78DC1A1F7357EC00C084F0 /* HLJNavigationStackViewController.h */, 239 | 4C78DC1B1F7357EC00C084F0 /* HLJNavigationStackViewController.m */, 240 | 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */, 241 | 6003F5A5195388D20070C39A /* hljViewController.h */, 242 | 6003F5A6195388D20070C39A /* hljViewController.m */, 243 | 71719F9D1E33DC2100824A3D /* LaunchScreen.storyboard */, 244 | 6003F5A8195388D20070C39A /* Images.xcassets */, 245 | 6003F594195388D20070C39A /* Supporting Files */, 246 | ); 247 | name = "Example for HLJNavigationBar"; 248 | path = HLJNavigationBar; 249 | sourceTree = ""; 250 | }; 251 | 6003F594195388D20070C39A /* Supporting Files */ = { 252 | isa = PBXGroup; 253 | children = ( 254 | 6003F595195388D20070C39A /* HLJNavigationBar-Info.plist */, 255 | 6003F596195388D20070C39A /* InfoPlist.strings */, 256 | 6003F599195388D20070C39A /* main.m */, 257 | 6003F59B195388D20070C39A /* HLJNavigationBar-Prefix.pch */, 258 | ); 259 | name = "Supporting Files"; 260 | sourceTree = ""; 261 | }; 262 | 6003F5B5195388D20070C39A /* Tests */ = { 263 | isa = PBXGroup; 264 | children = ( 265 | 6003F5BB195388D20070C39A /* Tests.m */, 266 | 6003F5B6195388D20070C39A /* Supporting Files */, 267 | ); 268 | path = Tests; 269 | sourceTree = ""; 270 | }; 271 | 6003F5B6195388D20070C39A /* Supporting Files */ = { 272 | isa = PBXGroup; 273 | children = ( 274 | 6003F5B7195388D20070C39A /* Tests-Info.plist */, 275 | 6003F5B8195388D20070C39A /* InfoPlist.strings */, 276 | 606FC2411953D9B200FFA9A0 /* Tests-Prefix.pch */, 277 | ); 278 | name = "Supporting Files"; 279 | sourceTree = ""; 280 | }; 281 | 60FF7A9C1954A5C5007DD14C /* Podspec Metadata */ = { 282 | isa = PBXGroup; 283 | children = ( 284 | 70B572EC6308951921A6EDFC /* HLJNavigationBar.podspec */, 285 | 7270D1AA9D9BED50734E01E1 /* README.md */, 286 | AFC1245B22D10E5FC733AD4A /* LICENSE */, 287 | ); 288 | name = "Podspec Metadata"; 289 | sourceTree = ""; 290 | }; 291 | 8DFEA5B1063AD41DF1B8EA69 /* Pods */ = { 292 | isa = PBXGroup; 293 | children = ( 294 | F55E343F8249BD0C392707D3 /* Pods-HLJNavigationBar_Example.debug.xcconfig */, 295 | 889A507865748C7A9B3460DC /* Pods-HLJNavigationBar_Example.release.xcconfig */, 296 | ); 297 | name = Pods; 298 | sourceTree = ""; 299 | }; 300 | /* End PBXGroup section */ 301 | 302 | /* Begin PBXNativeTarget section */ 303 | 6003F589195388D20070C39A /* HLJNavigationBar_Example */ = { 304 | isa = PBXNativeTarget; 305 | buildConfigurationList = 6003F5BF195388D20070C39A /* Build configuration list for PBXNativeTarget "HLJNavigationBar_Example" */; 306 | buildPhases = ( 307 | 19C7AD186B35ED26682B3093 /* [CP] Check Pods Manifest.lock */, 308 | 6003F586195388D20070C39A /* Sources */, 309 | 6003F587195388D20070C39A /* Frameworks */, 310 | 6003F588195388D20070C39A /* Resources */, 311 | 41FFDE6BF5077C5AC2634F62 /* [CP] Embed Pods Frameworks */, 312 | 124BEEA65F47C5E5E5A22FDA /* [CP] Copy Pods Resources */, 313 | ); 314 | buildRules = ( 315 | ); 316 | dependencies = ( 317 | ); 318 | name = HLJNavigationBar_Example; 319 | productName = HLJNavigationBar; 320 | productReference = 6003F58A195388D20070C39A /* HLJNavigationBar_Example.app */; 321 | productType = "com.apple.product-type.application"; 322 | }; 323 | 6003F5AD195388D20070C39A /* HLJNavigationBar_Tests */ = { 324 | isa = PBXNativeTarget; 325 | buildConfigurationList = 6003F5C2195388D20070C39A /* Build configuration list for PBXNativeTarget "HLJNavigationBar_Tests" */; 326 | buildPhases = ( 327 | 6003F5AA195388D20070C39A /* Sources */, 328 | 6003F5AB195388D20070C39A /* Frameworks */, 329 | 6003F5AC195388D20070C39A /* Resources */, 330 | ); 331 | buildRules = ( 332 | ); 333 | dependencies = ( 334 | 6003F5B4195388D20070C39A /* PBXTargetDependency */, 335 | ); 336 | name = HLJNavigationBar_Tests; 337 | productName = HLJNavigationBarTests; 338 | productReference = 6003F5AE195388D20070C39A /* HLJNavigationBar_Tests.xctest */; 339 | productType = "com.apple.product-type.bundle.unit-test"; 340 | }; 341 | /* End PBXNativeTarget section */ 342 | 343 | /* Begin PBXProject section */ 344 | 6003F582195388D10070C39A /* Project object */ = { 345 | isa = PBXProject; 346 | attributes = { 347 | CLASSPREFIX = HLJ; 348 | LastUpgradeCheck = 0720; 349 | ORGANIZATIONNAME = bullet_wu; 350 | TargetAttributes = { 351 | 6003F589195388D20070C39A = { 352 | DevelopmentTeam = YUHD86NT78; 353 | }; 354 | 6003F5AD195388D20070C39A = { 355 | TestTargetID = 6003F589195388D20070C39A; 356 | }; 357 | }; 358 | }; 359 | buildConfigurationList = 6003F585195388D10070C39A /* Build configuration list for PBXProject "HLJNavigationBar" */; 360 | compatibilityVersion = "Xcode 3.2"; 361 | developmentRegion = English; 362 | hasScannedForEncodings = 0; 363 | knownRegions = ( 364 | en, 365 | Base, 366 | ); 367 | mainGroup = 6003F581195388D10070C39A; 368 | productRefGroup = 6003F58B195388D20070C39A /* Products */; 369 | projectDirPath = ""; 370 | projectRoot = ""; 371 | targets = ( 372 | 6003F589195388D20070C39A /* HLJNavigationBar_Example */, 373 | 6003F5AD195388D20070C39A /* HLJNavigationBar_Tests */, 374 | ); 375 | }; 376 | /* End PBXProject section */ 377 | 378 | /* Begin PBXResourcesBuildPhase section */ 379 | 6003F588195388D20070C39A /* Resources */ = { 380 | isa = PBXResourcesBuildPhase; 381 | buildActionMask = 2147483647; 382 | files = ( 383 | 873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */, 384 | 71719F9F1E33DC2100824A3D /* LaunchScreen.storyboard in Resources */, 385 | 6003F5A9195388D20070C39A /* Images.xcassets in Resources */, 386 | 6003F598195388D20070C39A /* InfoPlist.strings in Resources */, 387 | ); 388 | runOnlyForDeploymentPostprocessing = 0; 389 | }; 390 | 6003F5AC195388D20070C39A /* Resources */ = { 391 | isa = PBXResourcesBuildPhase; 392 | buildActionMask = 2147483647; 393 | files = ( 394 | 6003F5BA195388D20070C39A /* InfoPlist.strings in Resources */, 395 | ); 396 | runOnlyForDeploymentPostprocessing = 0; 397 | }; 398 | /* End PBXResourcesBuildPhase section */ 399 | 400 | /* Begin PBXShellScriptBuildPhase section */ 401 | 124BEEA65F47C5E5E5A22FDA /* [CP] Copy Pods Resources */ = { 402 | isa = PBXShellScriptBuildPhase; 403 | buildActionMask = 2147483647; 404 | files = ( 405 | ); 406 | inputPaths = ( 407 | "${SRCROOT}/Pods/Target Support Files/Pods-HLJNavigationBar_Example/Pods-HLJNavigationBar_Example-resources.sh", 408 | "${PODS_ROOT}/MJRefresh/MJRefresh/MJRefresh.bundle", 409 | ); 410 | name = "[CP] Copy Pods Resources"; 411 | outputPaths = ( 412 | "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}", 413 | ); 414 | runOnlyForDeploymentPostprocessing = 0; 415 | shellPath = /bin/sh; 416 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-HLJNavigationBar_Example/Pods-HLJNavigationBar_Example-resources.sh\"\n"; 417 | showEnvVarsInLog = 0; 418 | }; 419 | 19C7AD186B35ED26682B3093 /* [CP] Check Pods Manifest.lock */ = { 420 | isa = PBXShellScriptBuildPhase; 421 | buildActionMask = 2147483647; 422 | files = ( 423 | ); 424 | inputPaths = ( 425 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 426 | "${PODS_ROOT}/Manifest.lock", 427 | ); 428 | name = "[CP] Check Pods Manifest.lock"; 429 | outputPaths = ( 430 | "$(DERIVED_FILE_DIR)/Pods-HLJNavigationBar_Example-checkManifestLockResult.txt", 431 | ); 432 | runOnlyForDeploymentPostprocessing = 0; 433 | shellPath = /bin/sh; 434 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 435 | showEnvVarsInLog = 0; 436 | }; 437 | 41FFDE6BF5077C5AC2634F62 /* [CP] Embed Pods Frameworks */ = { 438 | isa = PBXShellScriptBuildPhase; 439 | buildActionMask = 2147483647; 440 | files = ( 441 | ); 442 | inputPaths = ( 443 | ); 444 | name = "[CP] Embed Pods Frameworks"; 445 | outputPaths = ( 446 | ); 447 | runOnlyForDeploymentPostprocessing = 0; 448 | shellPath = /bin/sh; 449 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-HLJNavigationBar_Example/Pods-HLJNavigationBar_Example-frameworks.sh\"\n"; 450 | showEnvVarsInLog = 0; 451 | }; 452 | /* End PBXShellScriptBuildPhase section */ 453 | 454 | /* Begin PBXSourcesBuildPhase section */ 455 | 6003F586195388D20070C39A /* Sources */ = { 456 | isa = PBXSourcesBuildPhase; 457 | buildActionMask = 2147483647; 458 | files = ( 459 | 4C4C247D1F564543000309D9 /* HLJTestViewController.m in Sources */, 460 | 6003F59E195388D20070C39A /* AppDelegate.m in Sources */, 461 | 4C4C24801F5647EC000309D9 /* HLJHiddenNavBarViewController.m in Sources */, 462 | 6003F5A7195388D20070C39A /* hljViewController.m in Sources */, 463 | 2781A1191F7BAF630016CAB1 /* HLJFixedSpaceTestViewController.m in Sources */, 464 | 4C2EB8C91F5D24070031FFBF /* HLJBackActionViewController.m in Sources */, 465 | 4CC4A6961F568B12006F9E59 /* HLJNavBarTitleViewController.m in Sources */, 466 | 4C2EB8CC1F5D26160031FFBF /* HLJAddChildContainerViewController.m in Sources */, 467 | 4CC4A6991F568BB7006F9E59 /* HLJColorGradientViewController.m in Sources */, 468 | 6003F59A195388D20070C39A /* main.m in Sources */, 469 | 4C4C24861F5656B0000309D9 /* HLJShadowImageViewController.m in Sources */, 470 | 4C4C24891F565792000309D9 /* HLJNavbarClearViewController.m in Sources */, 471 | 4C78DC1C1F7357EC00C084F0 /* HLJNavigationStackViewController.m in Sources */, 472 | ); 473 | runOnlyForDeploymentPostprocessing = 0; 474 | }; 475 | 6003F5AA195388D20070C39A /* Sources */ = { 476 | isa = PBXSourcesBuildPhase; 477 | buildActionMask = 2147483647; 478 | files = ( 479 | 6003F5BC195388D20070C39A /* Tests.m in Sources */, 480 | ); 481 | runOnlyForDeploymentPostprocessing = 0; 482 | }; 483 | /* End PBXSourcesBuildPhase section */ 484 | 485 | /* Begin PBXTargetDependency section */ 486 | 6003F5B4195388D20070C39A /* PBXTargetDependency */ = { 487 | isa = PBXTargetDependency; 488 | target = 6003F589195388D20070C39A /* HLJNavigationBar_Example */; 489 | targetProxy = 6003F5B3195388D20070C39A /* PBXContainerItemProxy */; 490 | }; 491 | /* End PBXTargetDependency section */ 492 | 493 | /* Begin PBXVariantGroup section */ 494 | 6003F596195388D20070C39A /* InfoPlist.strings */ = { 495 | isa = PBXVariantGroup; 496 | children = ( 497 | 6003F597195388D20070C39A /* en */, 498 | ); 499 | name = InfoPlist.strings; 500 | sourceTree = ""; 501 | }; 502 | 6003F5B8195388D20070C39A /* InfoPlist.strings */ = { 503 | isa = PBXVariantGroup; 504 | children = ( 505 | 6003F5B9195388D20070C39A /* en */, 506 | ); 507 | name = InfoPlist.strings; 508 | sourceTree = ""; 509 | }; 510 | 71719F9D1E33DC2100824A3D /* LaunchScreen.storyboard */ = { 511 | isa = PBXVariantGroup; 512 | children = ( 513 | 71719F9E1E33DC2100824A3D /* Base */, 514 | ); 515 | name = LaunchScreen.storyboard; 516 | sourceTree = ""; 517 | }; 518 | /* End PBXVariantGroup section */ 519 | 520 | /* Begin XCBuildConfiguration section */ 521 | 6003F5BD195388D20070C39A /* Debug */ = { 522 | isa = XCBuildConfiguration; 523 | buildSettings = { 524 | ALWAYS_SEARCH_USER_PATHS = NO; 525 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 526 | CLANG_CXX_LIBRARY = "libc++"; 527 | CLANG_ENABLE_MODULES = YES; 528 | CLANG_ENABLE_OBJC_ARC = YES; 529 | CLANG_WARN_BOOL_CONVERSION = YES; 530 | CLANG_WARN_CONSTANT_CONVERSION = YES; 531 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 532 | CLANG_WARN_EMPTY_BODY = YES; 533 | CLANG_WARN_ENUM_CONVERSION = YES; 534 | CLANG_WARN_INT_CONVERSION = YES; 535 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 536 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 537 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 538 | COPY_PHASE_STRIP = NO; 539 | ENABLE_TESTABILITY = YES; 540 | GCC_C_LANGUAGE_STANDARD = gnu99; 541 | GCC_DYNAMIC_NO_PIC = NO; 542 | GCC_OPTIMIZATION_LEVEL = 0; 543 | GCC_PREPROCESSOR_DEFINITIONS = ( 544 | "DEBUG=1", 545 | "$(inherited)", 546 | ); 547 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 548 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 549 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 550 | GCC_WARN_UNDECLARED_SELECTOR = YES; 551 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 552 | GCC_WARN_UNUSED_FUNCTION = YES; 553 | GCC_WARN_UNUSED_VARIABLE = YES; 554 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 555 | ONLY_ACTIVE_ARCH = YES; 556 | SDKROOT = iphoneos; 557 | TARGETED_DEVICE_FAMILY = "1,2"; 558 | }; 559 | name = Debug; 560 | }; 561 | 6003F5BE195388D20070C39A /* Release */ = { 562 | isa = XCBuildConfiguration; 563 | buildSettings = { 564 | ALWAYS_SEARCH_USER_PATHS = NO; 565 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 566 | CLANG_CXX_LIBRARY = "libc++"; 567 | CLANG_ENABLE_MODULES = YES; 568 | CLANG_ENABLE_OBJC_ARC = YES; 569 | CLANG_WARN_BOOL_CONVERSION = YES; 570 | CLANG_WARN_CONSTANT_CONVERSION = YES; 571 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 572 | CLANG_WARN_EMPTY_BODY = YES; 573 | CLANG_WARN_ENUM_CONVERSION = YES; 574 | CLANG_WARN_INT_CONVERSION = YES; 575 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 576 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 577 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 578 | COPY_PHASE_STRIP = YES; 579 | ENABLE_NS_ASSERTIONS = NO; 580 | GCC_C_LANGUAGE_STANDARD = gnu99; 581 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 582 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 583 | GCC_WARN_UNDECLARED_SELECTOR = YES; 584 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 585 | GCC_WARN_UNUSED_FUNCTION = YES; 586 | GCC_WARN_UNUSED_VARIABLE = YES; 587 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 588 | SDKROOT = iphoneos; 589 | TARGETED_DEVICE_FAMILY = "1,2"; 590 | VALIDATE_PRODUCT = YES; 591 | }; 592 | name = Release; 593 | }; 594 | 6003F5C0195388D20070C39A /* Debug */ = { 595 | isa = XCBuildConfiguration; 596 | baseConfigurationReference = F55E343F8249BD0C392707D3 /* Pods-HLJNavigationBar_Example.debug.xcconfig */; 597 | buildSettings = { 598 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 599 | DEVELOPMENT_TEAM = YUHD86NT78; 600 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 601 | GCC_PREFIX_HEADER = "HLJNavigationBar/HLJNavigationBar-Prefix.pch"; 602 | INFOPLIST_FILE = "HLJNavigationBar/HLJNavigationBar-Info.plist"; 603 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 604 | MODULE_NAME = ExampleApp; 605 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}"; 606 | PRODUCT_NAME = "$(TARGET_NAME)"; 607 | WRAPPER_EXTENSION = app; 608 | }; 609 | name = Debug; 610 | }; 611 | 6003F5C1195388D20070C39A /* Release */ = { 612 | isa = XCBuildConfiguration; 613 | baseConfigurationReference = 889A507865748C7A9B3460DC /* Pods-HLJNavigationBar_Example.release.xcconfig */; 614 | buildSettings = { 615 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 616 | DEVELOPMENT_TEAM = YUHD86NT78; 617 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 618 | GCC_PREFIX_HEADER = "HLJNavigationBar/HLJNavigationBar-Prefix.pch"; 619 | INFOPLIST_FILE = "HLJNavigationBar/HLJNavigationBar-Info.plist"; 620 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 621 | MODULE_NAME = ExampleApp; 622 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}"; 623 | PRODUCT_NAME = "$(TARGET_NAME)"; 624 | WRAPPER_EXTENSION = app; 625 | }; 626 | name = Release; 627 | }; 628 | 6003F5C3195388D20070C39A /* Debug */ = { 629 | isa = XCBuildConfiguration; 630 | buildSettings = { 631 | BUNDLE_LOADER = "$(TEST_HOST)"; 632 | FRAMEWORK_SEARCH_PATHS = ( 633 | "$(SDKROOT)/Developer/Library/Frameworks", 634 | "$(inherited)", 635 | "$(DEVELOPER_FRAMEWORKS_DIR)", 636 | ); 637 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 638 | GCC_PREFIX_HEADER = "Tests/Tests-Prefix.pch"; 639 | GCC_PREPROCESSOR_DEFINITIONS = ( 640 | "DEBUG=1", 641 | "$(inherited)", 642 | ); 643 | INFOPLIST_FILE = "Tests/Tests-Info.plist"; 644 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}"; 645 | PRODUCT_NAME = "$(TARGET_NAME)"; 646 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/HLJNavigationBar_Example.app/HLJNavigationBar_Example"; 647 | WRAPPER_EXTENSION = xctest; 648 | }; 649 | name = Debug; 650 | }; 651 | 6003F5C4195388D20070C39A /* Release */ = { 652 | isa = XCBuildConfiguration; 653 | buildSettings = { 654 | BUNDLE_LOADER = "$(TEST_HOST)"; 655 | FRAMEWORK_SEARCH_PATHS = ( 656 | "$(SDKROOT)/Developer/Library/Frameworks", 657 | "$(inherited)", 658 | "$(DEVELOPER_FRAMEWORKS_DIR)", 659 | ); 660 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 661 | GCC_PREFIX_HEADER = "Tests/Tests-Prefix.pch"; 662 | INFOPLIST_FILE = "Tests/Tests-Info.plist"; 663 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}"; 664 | PRODUCT_NAME = "$(TARGET_NAME)"; 665 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/HLJNavigationBar_Example.app/HLJNavigationBar_Example"; 666 | WRAPPER_EXTENSION = xctest; 667 | }; 668 | name = Release; 669 | }; 670 | /* End XCBuildConfiguration section */ 671 | 672 | /* Begin XCConfigurationList section */ 673 | 6003F585195388D10070C39A /* Build configuration list for PBXProject "HLJNavigationBar" */ = { 674 | isa = XCConfigurationList; 675 | buildConfigurations = ( 676 | 6003F5BD195388D20070C39A /* Debug */, 677 | 6003F5BE195388D20070C39A /* Release */, 678 | ); 679 | defaultConfigurationIsVisible = 0; 680 | defaultConfigurationName = Release; 681 | }; 682 | 6003F5BF195388D20070C39A /* Build configuration list for PBXNativeTarget "HLJNavigationBar_Example" */ = { 683 | isa = XCConfigurationList; 684 | buildConfigurations = ( 685 | 6003F5C0195388D20070C39A /* Debug */, 686 | 6003F5C1195388D20070C39A /* Release */, 687 | ); 688 | defaultConfigurationIsVisible = 0; 689 | defaultConfigurationName = Release; 690 | }; 691 | 6003F5C2195388D20070C39A /* Build configuration list for PBXNativeTarget "HLJNavigationBar_Tests" */ = { 692 | isa = XCConfigurationList; 693 | buildConfigurations = ( 694 | 6003F5C3195388D20070C39A /* Debug */, 695 | 6003F5C4195388D20070C39A /* Release */, 696 | ); 697 | defaultConfigurationIsVisible = 0; 698 | defaultConfigurationName = Release; 699 | }; 700 | /* End XCConfigurationList section */ 701 | }; 702 | rootObject = 6003F582195388D10070C39A /* Project object */; 703 | } 704 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar.xcodeproj/xcshareddata/xcschemes/HLJNavigationBar-Example.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 34 | 40 | 41 | 42 | 43 | 44 | 50 | 51 | 52 | 53 | 54 | 55 | 66 | 68 | 74 | 75 | 76 | 77 | 78 | 79 | 85 | 87 | 93 | 94 | 95 | 96 | 98 | 99 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // hljAppDelegate.h 3 | // HLJNavigationBar 4 | // 5 | // Created by bullet_wu on 08/29/2017. 6 | // Copyright (c) 2017 bullet_wu. All rights reserved. 7 | // 8 | 9 | @import UIKit; 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // hljAppDelegate.m 3 | // HLJNavigationBar 4 | // 5 | // Created by bullet_wu on 08/29/2017. 6 | // Copyright (c) 2017 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "HLJTestViewController.h" 11 | #import "UIImage+HLJNavBarExtend.h" 12 | #import "UINavigationBar+HLJNavigationItem.h" 13 | 14 | @implementation AppDelegate 15 | 16 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 17 | { 18 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 19 | self.window.backgroundColor = [UIColor whiteColor]; 20 | [self.window makeKeyAndVisible]; 21 | 22 | /** 23 | * 默认情况下tableview header和fooer颜色的设置 24 | */ 25 | if (@available(iOS 11.0, *)) { 26 | [[UIScrollView appearance] setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever]; 27 | // 去掉iOS11系统默认开启的self-sizing 28 | [UITableView appearance].estimatedRowHeight = 0; 29 | [UITableView appearance].estimatedSectionHeaderHeight = 0; 30 | [UITableView appearance].estimatedSectionFooterHeight = 0; 31 | } 32 | 33 | //配置一些ui信息(必须) 34 | [[UINavigationBar appearance] setHlj_backImage:[[UIImage imageNamed:@"icon_common_back_main"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]]; 35 | [[UINavigationBar appearance] setHlj_shadowColor:[UIColor grayColor]]; 36 | [[UINavigationBar appearance] setHlj_alpha:1]; 37 | [[UINavigationBar appearance] setHlj_backgroundColor:[UIColor whiteColor]]; 38 | [[UINavigationBar appearance] setHlj_barButtonItemTintColor:[UIColor redColor]]; 39 | [[UINavigationBar appearance] setHlj_barButtonItemFont:[UIFont systemFontOfSize:14.0]]; 40 | [[UINavigationBar appearance] setHlj_titleColor:[UIColor blackColor]]; 41 | [[UINavigationBar appearance] setHlj_font:[UIFont boldSystemFontOfSize:17.0]]; 42 | 43 | HLJTestViewController *viewController = [[HLJTestViewController alloc] init]; 44 | UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:viewController]; 45 | self.window.rootViewController = nav; 46 | 47 | return YES; 48 | } 49 | 50 | 51 | - (void)applicationWillResignActive:(UIApplication *)application 52 | { 53 | // 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. 54 | // 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. 55 | } 56 | 57 | - (void)applicationDidEnterBackground:(UIApplication *)application 58 | { 59 | // 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. 60 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 61 | } 62 | 63 | - (void)applicationWillEnterForeground:(UIApplication *)application 64 | { 65 | // 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. 66 | } 67 | 68 | - (void)applicationDidBecomeActive:(UIApplication *)application 69 | { 70 | // 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. 71 | } 72 | 73 | - (void)applicationWillTerminate:(UIApplication *)application 74 | { 75 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 76 | } 77 | 78 | @end 79 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/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 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/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 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/HLJAddChildContainerViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // HLJAddChildContainerViewController.h 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/9/4. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HLJAddChildContainerViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/HLJAddChildContainerViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // HLJAddChildContainerViewController.m 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/9/4. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import "HLJAddChildContainerViewController.h" 10 | #import "HLJColorGradientViewController.h" 11 | #import "UIViewController+HLJNavigationBar.h" 12 | #import "Masonry.h" 13 | 14 | @interface HLJAddChildContainerViewController () 15 | 16 | @end 17 | 18 | @implementation HLJAddChildContainerViewController 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | self.extendedLayoutIncludesOpaqueBars = YES; 23 | self.view.backgroundColor = [UIColor whiteColor]; 24 | self.automaticallyAdjustsScrollViewInsets = NO; 25 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 26 | HLJColorGradientViewController *viewController = [[HLJColorGradientViewController alloc] init]; 27 | [self addChildViewController:viewController]; 28 | [viewController setValue:self.navigationItem forKey:@"_navigationItem"]; 29 | viewController.title = @"测试"; 30 | viewController.view.frame = self.view.bounds; 31 | [self.view addSubview:viewController.view]; 32 | }); 33 | 34 | } 35 | 36 | 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/HLJBackActionViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // HLJBackActionViewController.h 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/9/4. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HLJBackActionViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/HLJBackActionViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // HLJBackActionViewController.m 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/9/4. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import "HLJBackActionViewController.h" 10 | #import "UIViewController+HLJBackHandlerProtocol.h" 11 | #import "UIImage+HLJNavBarExtend.h" 12 | #import "UIViewController+HLJNavigationBar.h" 13 | 14 | @interface HLJBackActionViewController () 15 | 16 | @property (nonatomic ,assign) BOOL shouldPop; 17 | 18 | @end 19 | 20 | @implementation HLJBackActionViewController 21 | 22 | - (void)viewDidLoad { 23 | [super viewDidLoad]; 24 | self.view.backgroundColor = [UIColor whiteColor]; 25 | 26 | self.shouldPop = NO; 27 | } 28 | 29 | - (BOOL)navigationShouldPop { 30 | if (!self.shouldPop) { 31 | UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:@"是否允许触发返回" preferredStyle:UIAlertControllerStyleAlert]; 32 | [alertController addAction:[UIAlertAction actionWithTitle:@"否" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { 33 | self.shouldPop = NO; 34 | }]]; 35 | [alertController addAction:[UIAlertAction actionWithTitle:@"是" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { 36 | self.shouldPop = YES; 37 | }]]; 38 | dispatch_async(dispatch_get_main_queue(), ^{ 39 | [self.navigationController presentViewController:alertController animated:YES completion:nil]; 40 | }); 41 | } 42 | return self.shouldPop; 43 | } 44 | 45 | - (void)navigationDidPop { 46 | NSLog(@"pop成功"); 47 | } 48 | 49 | - (void)navigationPopCancel { 50 | NSLog(@"侧滑返回取消"); 51 | } 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/HLJColorGradientViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // HLJColorGradientViewController.h 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/8/30. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HLJColorGradientViewController : UIViewController 12 | @property (nonatomic ,strong) UITableView *tableView; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/HLJColorGradientViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // HLJColorGradientViewController.m 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/8/30. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import "HLJColorGradientViewController.h" 10 | #import "Masonry.h" 11 | #import "UIViewController+HLJNavigationBar.h" 12 | #import "AppDelegate.h" 13 | #import "UIColor+HLJNavBarExtend.h" 14 | #import "UIBarButtonItem+HLJExtend.h" 15 | #import "UINavigationItem+HLJNavigationBar.h" 16 | #import "HLJNavBarTitleViewController.h" 17 | 18 | @interface HLJColorGradientViewController () 19 | 20 | @property (nonatomic ,strong) UIImageView *headView; 21 | @property (nonatomic ,assign) NSInteger maxCount; 22 | 23 | @end 24 | 25 | @implementation HLJColorGradientViewController 26 | 27 | - (void)viewDidLoad { 28 | [super viewDidLoad]; 29 | self.navigationItem.hlj_navBarBgAlpha = 0; 30 | [self hlj_setNeedsNavigationItemLayout]; 31 | self.navigationItem.hlj_navBarTitleColor = [UIColor blackColor]; 32 | self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:self action:nil]; 33 | 34 | UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)]; 35 | [button setTitle:@"变色" forState:UIControlStateNormal]; 36 | button.titleLabel.font = [UIFont systemFontOfSize:14.0]; 37 | [button addTarget:self action:@selector(onTapClick) forControlEvents:UIControlEventTouchUpInside]; 38 | [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal]; 39 | // [button setImage:[[UIImage imageNamed:@"icon_common_message"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal]; 40 | UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button]; 41 | 42 | UIButton *unButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)]; 43 | [unButton setTitle:@"不变色" forState:UIControlStateNormal]; 44 | unButton.titleLabel.font = [UIFont systemFontOfSize:14.0]; 45 | [unButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal]; 46 | // [unButton setImage:[[UIImage imageNamed:@"icon_common_message"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal]; 47 | UIBarButtonItem *unRightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:unButton]; 48 | unRightBarButtonItem.hlj_isChangeTintColor = NO; //控制按钮是否需要变色 49 | self.navigationItem.rightBarButtonItems = @[rightBarButtonItem,unRightBarButtonItem]; 50 | // self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"按钮" style:UIBarButtonItemStyleDone target:self action:nil]; 51 | 52 | //iOS11 发现这里如果用约束 一旦导航栏用有透明度的图片 侧滑返回 会影响前面一个页面的self.view的y坐标位置, 53 | // self.tableView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); 54 | self.extendedLayoutIncludesOpaqueBars = YES; 55 | adjustsScrollViewInsets_NO(self.tableView, self); 56 | [self.view addSubview:self.tableView]; 57 | [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { 58 | make.edges.mas_equalTo(self.view); 59 | }]; 60 | 61 | // self.tableView.contentInset = UIEdgeInsetsMake(-(44+[[UIApplication sharedApplication] statusBarFrame].size.height), 0, 0, 0); 62 | self.headView.frame = CGRectMake(0, 0, self.view.frame.size.width, 200.0); 63 | self.tableView.tableHeaderView = self.headView; 64 | 65 | [self.tableView layoutIfNeeded]; 66 | [self updateNavBarStyle]; 67 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 68 | self.maxCount = 1; 69 | [self.tableView reloadData]; 70 | }); 71 | } 72 | 73 | 74 | - (void)viewDidAppear:(BOOL)animated { 75 | [super viewDidAppear:animated]; 76 | NSLog(@"self:%zd",self.navigationController.navigationBar.translucent); 77 | } 78 | 79 | - (void)onTapClick { 80 | HLJNavBarTitleViewController *viewController = [[HLJNavBarTitleViewController alloc] init]; 81 | [self.navigationController pushViewController:viewController animated:YES]; 82 | } 83 | 84 | #pragma mark tableviewDelegate & tableViewDataSource 85 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 86 | return self.maxCount; 87 | } 88 | 89 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 90 | return 30; 91 | } 92 | 93 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 94 | return 44; 95 | } 96 | 97 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 98 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([UITableViewCell class])]; 99 | if (!cell) { 100 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([UITableViewCell class])]; 101 | } 102 | cell.textLabel.text = @(indexPath.row).stringValue; 103 | return cell; 104 | } 105 | 106 | #pragma mark UIScrollViewDelegate 107 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView { 108 | [self updateNavBarStyle]; 109 | } 110 | 111 | - (void)updateNavBarStyle { 112 | CGFloat height = self.tableView.tableHeaderView.frame.size.height; 113 | CGFloat percentComplete = (height - (self.tableView.contentOffset.y))/height; 114 | if (percentComplete <= 0) { 115 | percentComplete = 0; 116 | } 117 | if (percentComplete >= 1) { 118 | percentComplete = 1; 119 | } 120 | self.navigationItem.hlj_navBarBgAlpha = 1 - percentComplete; 121 | UIColor *startColor = [UIColor blackColor]; 122 | UIColor *endColor = [UIColor whiteColor]; 123 | self.navigationItem.hlj_navBarTitleColor = [UIColor hlj_HLJNavBar_mixColor1:startColor color2:endColor ratio:percentComplete]; 124 | self.navigationItem.hlj_barButtonItemTintColor = [UIColor hlj_HLJNavBar_mixColor1:startColor color2:endColor ratio:percentComplete]; 125 | [self hlj_setNeedsNavigationItemLayout]; 126 | } 127 | 128 | 129 | #pragma mark - getters and setters 130 | - (UITableView *)tableView { 131 | if (!_tableView) { 132 | _tableView = [[UITableView alloc] init]; 133 | _tableView.backgroundColor = [UIColor redColor]; 134 | _tableView.delegate = self; 135 | _tableView.dataSource = self; 136 | } 137 | return _tableView; 138 | } 139 | 140 | - (UIImageView *)headView { 141 | if (!_headView) { 142 | _headView = [[UIImageView alloc] init]; 143 | _headView.image = [UIImage imageNamed:@"image4"]; 144 | _headView.backgroundColor = [UIColor yellowColor]; 145 | } 146 | return _headView; 147 | } 148 | 149 | @end 150 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/HLJFixedSpaceTestViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // HLJFixedSpaceTestViewController.h 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 项元智 on 2017/9/27. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HLJFixedSpaceTestViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/HLJFixedSpaceTestViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // HLJFixedSpaceTestViewController.m 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 项元智 on 2017/9/27. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import "HLJFixedSpaceTestViewController.h" 10 | #import "UINavigationItem+HLJFixSpace.h" 11 | #import "UIView+HLJIntrinsicContentSize.h" 12 | #import "UINavigationItem+HLJNavigationBar.h" 13 | 14 | @interface HLJFixedSpaceTestViewController () 15 | @property(nonatomic, strong) UIBarButtonItem *leftBarButton; 16 | @property(nonatomic, strong) UIBarButtonItem *rightBarButton; 17 | @end 18 | 19 | @implementation HLJFixedSpaceTestViewController 20 | 21 | - (void)viewDidLoad { 22 | [super viewDidLoad]; 23 | // Do any additional setup after loading the view. 24 | 25 | self.view.backgroundColor = [UIColor whiteColor]; 26 | self.navigationItem.hlj_barButtonItemTintColor = [UIColor redColor]; 27 | 28 | UIBarButtonItem *fixedSpaceItem = [self fixedSpaceWithWidth:-15]; 29 | [self.navigationItem setLeftBarButtonItems:@[fixedSpaceItem, self.leftBarButton]]; 30 | 31 | fixedSpaceItem = [self fixedSpaceWithWidth:-15]; 32 | [self.navigationItem setRightBarButtonItems:@[fixedSpaceItem, self.rightBarButton]]; 33 | } 34 | 35 | - (void)didReceiveMemoryWarning { 36 | [super didReceiveMemoryWarning]; 37 | // Dispose of any resources that can be recreated. 38 | } 39 | 40 | -(void)cmdTest:(id)sender { 41 | 42 | UIBarButtonItem *fixedSpaceItem = [self fixedSpaceWithWidth:-5]; 43 | [self.navigationItem setLeftBarButtonItems:@[fixedSpaceItem, self.leftBarButton]]; 44 | } 45 | 46 | -(void)cmdTest2:(id)sender { 47 | 48 | UIBarButtonItem *fixedSpaceItem = [self fixedSpaceWithWidth:-1]; 49 | [self.navigationItem setLeftBarButtonItems:@[fixedSpaceItem, self.leftBarButton]]; 50 | } 51 | 52 | -(UIBarButtonItem *)fixedSpaceWithWidth:(CGFloat)width { 53 | UIBarButtonItem *fixedSpace = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace 54 | target:nil 55 | action:nil]; 56 | fixedSpace.width = width; 57 | return fixedSpace; 58 | } 59 | 60 | -(UIBarButtonItem *)leftBarButton { 61 | //if(_leftBarButton == nil) { 62 | 63 | UIButton *leftButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)]; 64 | leftButton.backgroundColor = [UIColor greenColor]; 65 | leftButton.hlj_intrinsicContentSize = CGSizeMake(44, 44); 66 | [leftButton addTarget:self action:@selector(cmdTest2:) forControlEvents:UIControlEventTouchUpInside]; 67 | 68 | _leftBarButton = [[UIBarButtonItem alloc] initWithCustomView:leftButton]; 69 | //} 70 | return _leftBarButton; 71 | } 72 | 73 | -(UIBarButtonItem *)rightBarButton { 74 | 75 | //if(_rightBarButton == nil) { 76 | 77 | UIButton *rightButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)]; 78 | rightButton.backgroundColor = [UIColor redColor]; 79 | rightButton.hlj_intrinsicContentSize = CGSizeMake(44, 44); 80 | [rightButton addTarget:self action:@selector(cmdTest:) forControlEvents:UIControlEventTouchUpInside]; 81 | 82 | _rightBarButton = [[UIBarButtonItem alloc] initWithCustomView:rightButton]; 83 | //} 84 | return _rightBarButton; 85 | } 86 | 87 | 88 | @end 89 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/HLJHiddenNavBarViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // HLJHiddenNavBarViewController.h 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/8/30. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HLJHiddenNavBarViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/HLJHiddenNavBarViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // HLJHiddenNavBarViewController.m 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/8/30. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import "HLJHiddenNavBarViewController.h" 10 | #import "UIViewController+HLJNavigationBar.h" 11 | #import "UIViewController+HLJBackHandlerProtocol.h" 12 | 13 | @interface HLJHiddenNavBarViewController () 14 | 15 | @end 16 | 17 | @implementation HLJHiddenNavBarViewController 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | self.hlj_prefersNavigationBarHidden = YES; 22 | self.view.backgroundColor = [UIColor whiteColor]; 23 | } 24 | 25 | - (BOOL)navigationShouldPop { 26 | return YES; 27 | } 28 | 29 | - (void)navigationDidPop { 30 | NSLog(@"pop成功"); 31 | } 32 | 33 | - (void)navigationPopCancel { 34 | NSLog(@"侧滑返回取消"); 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/HLJNavBarTitleViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // HLJNavBarImageViewController.h 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/8/30. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HLJNavBarTitleViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/HLJNavBarTitleViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // HLJNavBarImageViewController.m 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/8/30. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import "HLJNavBarTitleViewController.h" 10 | #import "UIViewController+HLJNavigationBar.h" 11 | #import "Masonry.h" 12 | #import "UIColor+HLJNavBarExtend.h" 13 | #import "UIImage+HLJNavBarExtend.h" 14 | #import "UINavigationItem+HLJNavigationBar.h" 15 | #import "UIView+HLJIntrinsicContentSize.h" 16 | 17 | @interface HLJNavBarTitleViewController () 18 | 19 | @end 20 | 21 | @implementation HLJNavBarTitleViewController 22 | 23 | - (instancetype)init { 24 | self = [super init]; 25 | if (self) { 26 | self.navigationItem.hlj_navBarBackgroundColor = [UIColor blueColor]; 27 | } 28 | return self; 29 | } 30 | 31 | - (void)viewDidLoad { 32 | [super viewDidLoad]; 33 | // 34 | // [self hlj_setNeedsNavigationItemLayout]; 35 | 36 | self.view.backgroundColor = [UIColor whiteColor]; 37 | 38 | self.navigationItem.title = @"测试"; 39 | UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil]; 40 | item.width = 0; 41 | self.navigationItem.rightBarButtonItems = @[item,[[UIBarButtonItem alloc] initWithTitle:@"按钮" style:UIBarButtonItemStyleDone target:self action:nil],[[UIBarButtonItem alloc] initWithTitle:@"按钮" style:UIBarButtonItemStyleDone target:self action:nil]]; 42 | self.navigationItem.hlj_barButtonItemTintColor = [UIColor redColor]; 43 | } 44 | 45 | - (void)viewWillAppear:(BOOL)animated { 46 | [super viewWillAppear:animated]; 47 | NSLog(@"%@:viewWillAppear",NSStringFromClass([self class])); 48 | } 49 | 50 | - (void)viewDidAppear:(BOOL)animated { 51 | [super viewDidAppear:animated]; 52 | NSLog(@"%@:viewDidAppear",NSStringFromClass([self class])); 53 | } 54 | 55 | - (void)viewWillDisappear:(BOOL)animated { 56 | [super viewWillDisappear:animated]; 57 | NSLog(@"%@:viewWillDisappear",NSStringFromClass([self class])); 58 | } 59 | 60 | - (void)viewDidDisappear:(BOOL)animated { 61 | [super viewDidDisappear:animated]; 62 | NSLog(@"%@:viewDidDisappear",NSStringFromClass([self class])); 63 | } 64 | 65 | #pragma mark UISearchBarDelegate 66 | - (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar { 67 | return YES; 68 | } 69 | 70 | 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/HLJNavbarClearViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // HLJNavbarClearViewController.h 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/8/30. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HLJNavbarClearViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/HLJNavbarClearViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // HLJNavbarClearViewController.m 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/8/30. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import "HLJNavbarClearViewController.h" 10 | #import "UIViewController+HLJNavigationBar.h" 11 | #import "UIImage+HLJNavBarExtend.h" 12 | #import "UINavigationItem+HLJNavigationBar.h" 13 | 14 | @interface HLJNavbarClearViewController () 15 | 16 | 17 | @end 18 | 19 | @implementation HLJNavbarClearViewController 20 | 21 | - (void)viewDidLoad { 22 | [super viewDidLoad]; 23 | self.view.backgroundColor = [UIColor yellowColor]; 24 | self.navigationItem.hlj_navBarBgAlpha = 0; 25 | [self hlj_setNeedsNavigationItemLayout]; 26 | 27 | 28 | } 29 | 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/HLJNavigationBar-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIStatusBarStyle 6 | UIStatusBarStyleDefault 7 | CFBundleDevelopmentRegion 8 | en 9 | CFBundleDisplayName 10 | ${PRODUCT_NAME} 11 | CFBundleExecutable 12 | ${EXECUTABLE_NAME} 13 | CFBundleIdentifier 14 | $(PRODUCT_BUNDLE_IDENTIFIER) 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.0 23 | CFBundleSignature 24 | ???? 25 | CFBundleVersion 26 | 1.0 27 | LSRequiresIPhoneOS 28 | 29 | UILaunchStoryboardName 30 | LaunchScreen 31 | UIMainStoryboardFile 32 | Main 33 | UIRequiredDeviceCapabilities 34 | 35 | armv7 36 | 37 | UISupportedInterfaceOrientations 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationLandscapeLeft 41 | UIInterfaceOrientationLandscapeRight 42 | 43 | UISupportedInterfaceOrientations~ipad 44 | 45 | UIInterfaceOrientationPortrait 46 | UIInterfaceOrientationPortraitUpsideDown 47 | UIInterfaceOrientationLandscapeLeft 48 | UIInterfaceOrientationLandscapeRight 49 | 50 | UIViewControllerBasedStatusBarAppearance 51 | 52 | UISupportedInterfaceOrientations - 2 53 | 54 | UIInterfaceOrientationPortrait 55 | 56 | NSCameraUsageDescription 57 | cameraDesciption 58 | NSContactsUsageDescription 59 | contactsDesciption 60 | NSMicrophoneUsageDescription 61 | microphoneDesciption 62 | NSPhotoLibraryUsageDescription 63 | photoLibraryDesciption 64 | 65 | 66 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/HLJNavigationBar-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_5_0 10 | #warning "This project uses features only available in iOS SDK 5.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | @import UIKit; 15 | @import Foundation; 16 | #endif 17 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/HLJNavigationStackViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // HLJNavigationStackViewController.h 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/9/21. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HLJNavigationStackViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/HLJNavigationStackViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // HLJNavigationStackViewController.m 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/9/21. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import "HLJNavigationStackViewController.h" 10 | 11 | @interface HLJNavigationStackViewController () 12 | 13 | @end 14 | 15 | @implementation HLJNavigationStackViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | 20 | // Do any additional setup after loading the view. 21 | } 22 | 23 | - (void)didReceiveMemoryWarning { 24 | [super didReceiveMemoryWarning]; 25 | // Dispose of any resources that can be recreated. 26 | } 27 | 28 | /* 29 | #pragma mark - Navigation 30 | 31 | // In a storyboard-based application, you will often want to do a little preparation before navigation 32 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 33 | // Get the new view controller using [segue destinationViewController]. 34 | // Pass the selected object to the new view controller. 35 | } 36 | */ 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/HLJShadowImageViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // HLJShadowImageViewController.h 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/8/30. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HLJShadowImageViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/HLJShadowImageViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // HLJShadowImageViewController.m 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/8/30. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import "HLJShadowImageViewController.h" 10 | #import "UIViewController+HLJNavigationBar.h" 11 | #import "UIImage+HLJNavBarExtend.h" 12 | #import "UINavigationItem+HLJNavigationBar.h" 13 | 14 | @interface HLJShadowImageViewController () 15 | 16 | @end 17 | 18 | @implementation HLJShadowImageViewController 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | self.navigationItem.hlj_navBarShadowColor = [UIColor yellowColor]; 23 | // UIColor *color = [UIColor colorWithPatternImage:self.navigationItem.hlj_navBarShadowImage]; 24 | self.view.backgroundColor = [UIColor whiteColor]; 25 | 26 | 27 | } 28 | 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/HLJTestViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // HLJTestViewController.h 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/8/30. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HLJTestViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/HLJTestViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // HLJTestViewController.m 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/8/30. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import "HLJTestViewController.h" 10 | #import "Masonry.h" 11 | #import "HLJHiddenNavBarViewController.h" 12 | #import "HLJShadowImageViewController.h" 13 | #import "HLJNavbarClearViewController.h" 14 | #import "HLJNavBarTitleViewController.h" 15 | #import "HLJColorGradientViewController.h" 16 | #import "HLJBackActionViewController.h" 17 | #import "HLJAddChildContainerViewController.h" 18 | #import "UIViewController+HLJNavigationBar.h" 19 | #import "UIImage+HLJNavBarExtend.h" 20 | #import "UINavigationItem+HLJNavigationBar.h" 21 | #import "HLJNavigationStackViewController.h" 22 | #import "HLJFixedSpaceTestViewController.h" 23 | #import "UINavigationBar+HLJNavigationItem.h" 24 | 25 | #define kTableArray @[@"hidden导航栏",@"导航栏分割线变色",@"导航栏背景透明",@"导航栏titleView自适应",@"颜色渐变",@"返回过程中的一些事件监听",@"addChildViewController对导航栏的影响",@"访问系统相册",@"整个导航模块变色", @"边距修改"] 26 | 27 | @interface HLJTestViewController () 28 | 29 | @property (nonatomic ,strong) UITableView *tableView; 30 | 31 | @end 32 | 33 | @implementation HLJTestViewController 34 | 35 | - (void)viewDidLoad { 36 | [super viewDidLoad]; 37 | self.title = @"测试"; 38 | [self.view addSubview:self.tableView]; 39 | [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { 40 | make.edges.mas_equalTo(self.view); 41 | }]; 42 | } 43 | 44 | - (void)viewWillAppear:(BOOL)animated { 45 | [super viewWillAppear:animated]; 46 | NSLog(@"%@:viewWillAppear",NSStringFromClass([self class])); 47 | 48 | } 49 | - (void)viewDidAppear:(BOOL)animated { 50 | [super viewDidAppear:animated]; 51 | NSLog(@"%@:viewDidAppear",NSStringFromClass([self class])); 52 | } 53 | 54 | - (void)viewWillDisappear:(BOOL)animated { 55 | [super viewWillDisappear:animated]; 56 | NSLog(@"%@:viewWillDisappear",NSStringFromClass([self class])); 57 | } 58 | 59 | - (void)viewDidDisappear:(BOOL)animated { 60 | [super viewDidDisappear:animated]; 61 | NSLog(@"%@:viewDidDisappear",NSStringFromClass([self class])); 62 | } 63 | 64 | 65 | #pragma mark tableviewDelegate & tableViewDataSource 66 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 67 | return 1; 68 | } 69 | 70 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 71 | return kTableArray.count; 72 | } 73 | 74 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 75 | return 44.0; 76 | } 77 | 78 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 79 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([UITableViewCell class])]; 80 | if (!cell) { 81 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([UITableViewCell class])]; 82 | } 83 | cell.textLabel.text = kTableArray[indexPath.row]; 84 | return cell; 85 | } 86 | 87 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 88 | if (indexPath.row == 0) { 89 | HLJHiddenNavBarViewController *viewController = [[HLJHiddenNavBarViewController alloc] init]; 90 | viewController.title = kTableArray[indexPath.row]; 91 | [self.navigationController pushViewController:viewController animated:YES]; 92 | }else if (indexPath.row == 1) { 93 | HLJShadowImageViewController *viewController = [[HLJShadowImageViewController alloc] init]; 94 | viewController.title = kTableArray[indexPath.row]; 95 | [self.navigationController pushViewController:viewController animated:YES]; 96 | }else if (indexPath.row == 2) { 97 | HLJNavbarClearViewController *viewController = [[HLJNavbarClearViewController alloc] init]; 98 | viewController.title = kTableArray[indexPath.row]; 99 | [self.navigationController pushViewController:viewController animated:YES]; 100 | }else if (indexPath.row == 3) { 101 | HLJNavBarTitleViewController *viewController = [[HLJNavBarTitleViewController alloc] init]; 102 | viewController.title = kTableArray[indexPath.row]; 103 | [self.navigationController pushViewController:viewController animated:YES]; 104 | }else if (indexPath.row == 4) { 105 | HLJColorGradientViewController *viewController = [[HLJColorGradientViewController alloc] init]; 106 | viewController.title = kTableArray[indexPath.row]; 107 | [self.navigationController pushViewController:viewController animated:YES]; 108 | }else if (indexPath.row == 5) { 109 | HLJBackActionViewController *viewController = [[HLJBackActionViewController alloc] init]; 110 | viewController.title = kTableArray[indexPath.row]; 111 | [self.navigationController pushViewController:viewController animated:YES]; 112 | }else if (indexPath.row == 6) { 113 | HLJAddChildContainerViewController *viewController = [[HLJAddChildContainerViewController alloc] init]; 114 | viewController.title = kTableArray[indexPath.row]; 115 | [self.navigationController pushViewController:viewController animated:YES]; 116 | }else if (indexPath.row == 7) { 117 | UIImagePickerController *pickerViewController = [[UIImagePickerController alloc] init]; 118 | [pickerViewController setSourceType:UIImagePickerControllerSourceTypePhotoLibrary]; 119 | [pickerViewController setAllowsEditing:YES]; 120 | [self.navigationController presentViewController:pickerViewController animated:YES completion:^{ 121 | }]; 122 | }else if (indexPath.row == 8) { 123 | HLJTestViewController *viewController = [[HLJTestViewController alloc] init]; 124 | UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:viewController]; 125 | nav.navigationBar.hlj_backgroundColor = [UIColor blueColor]; 126 | [self.navigationController presentViewController:nav animated:YES completion:nil]; 127 | // HLJHorizontalPageViewController *viewController = [[HLJHorizontalPageViewController alloc] init]; 128 | // [self.navigationController pushViewController:viewController animated:YES]; 129 | }else if(indexPath.row == 9) { 130 | HLJFixedSpaceTestViewController *viewController = [[HLJFixedSpaceTestViewController alloc] init]; 131 | viewController.title = kTableArray[indexPath.row]; 132 | [self.navigationController pushViewController:viewController animated:YES]; 133 | } 134 | } 135 | 136 | #pragma mark - getters and setters 137 | - (UITableView *)tableView { 138 | if (!_tableView) { 139 | _tableView = [[UITableView alloc] init]; 140 | _tableView.dataSource = self; 141 | _tableView.delegate = self; 142 | } 143 | return _tableView; 144 | } 145 | 146 | @end 147 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/Images.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 | } -------------------------------------------------------------------------------- /Example/HLJNavigationBar/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Example/HLJNavigationBar/Images.xcassets/icon_common_back_main.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "thinBackIcon_red@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "thinBackIcon_red@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /Example/HLJNavigationBar/Images.xcassets/icon_common_back_main.imageset/thinBackIcon_red@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BulletWu/HLJNavigationBar/cc176040bdb53341f90ba410373d55279dba548a/Example/HLJNavigationBar/Images.xcassets/icon_common_back_main.imageset/thinBackIcon_red@2x.png -------------------------------------------------------------------------------- /Example/HLJNavigationBar/Images.xcassets/icon_common_back_main.imageset/thinBackIcon_red@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BulletWu/HLJNavigationBar/cc176040bdb53341f90ba410373d55279dba548a/Example/HLJNavigationBar/Images.xcassets/icon_common_back_main.imageset/thinBackIcon_red@3x.png -------------------------------------------------------------------------------- /Example/HLJNavigationBar/Images.xcassets/icon_common_message.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "icon_common_groupMessage@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "icon_common_groupMessage@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /Example/HLJNavigationBar/Images.xcassets/icon_common_message.imageset/icon_common_groupMessage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BulletWu/HLJNavigationBar/cc176040bdb53341f90ba410373d55279dba548a/Example/HLJNavigationBar/Images.xcassets/icon_common_message.imageset/icon_common_groupMessage@2x.png -------------------------------------------------------------------------------- /Example/HLJNavigationBar/Images.xcassets/icon_common_message.imageset/icon_common_groupMessage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BulletWu/HLJNavigationBar/cc176040bdb53341f90ba410373d55279dba548a/Example/HLJNavigationBar/Images.xcassets/icon_common_message.imageset/icon_common_groupMessage@3x.png -------------------------------------------------------------------------------- /Example/HLJNavigationBar/Images.xcassets/image4.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "image4.jpeg", 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 | } -------------------------------------------------------------------------------- /Example/HLJNavigationBar/Images.xcassets/image4.imageset/image4.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BulletWu/HLJNavigationBar/cc176040bdb53341f90ba410373d55279dba548a/Example/HLJNavigationBar/Images.xcassets/image4.imageset/image4.jpeg -------------------------------------------------------------------------------- /Example/HLJNavigationBar/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/hljViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // hljViewController.h 3 | // HLJNavigationBar 4 | // 5 | // Created by bullet_wu on 08/29/2017. 6 | // Copyright (c) 2017 bullet_wu. All rights reserved. 7 | // 8 | 9 | @import UIKit; 10 | 11 | @interface hljViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/hljViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // hljViewController.m 3 | // HLJNavigationBar 4 | // 5 | // Created by bullet_wu on 08/29/2017. 6 | // Copyright (c) 2017 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import "hljViewController.h" 10 | 11 | @interface hljViewController () 12 | 13 | @end 14 | 15 | @implementation hljViewController 16 | 17 | - (void)viewDidLoad 18 | { 19 | [super viewDidLoad]; 20 | // Do any additional setup after loading the view, typically from a nib. 21 | } 22 | 23 | - (void)didReceiveMemoryWarning 24 | { 25 | [super didReceiveMemoryWarning]; 26 | // Dispose of any resources that can be recreated. 27 | } 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Example/HLJNavigationBar/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // HLJNavigationBar 4 | // 5 | // Created by bullet_wu on 08/29/2017. 6 | // Copyright (c) 2017 bullet_wu. All rights reserved. 7 | // 8 | 9 | @import UIKit; 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) 13 | { 14 | @autoreleasepool { 15 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Example/Podfile: -------------------------------------------------------------------------------- 1 | source 'https://github.com/CocoaPods/Specs.git' 2 | 3 | target 'HLJNavigationBar_Example' do 4 | pod 'HLJNavigationBar', :path => '../' 5 | pod 'Masonry' 6 | pod 'MJRefresh' 7 | pod 'ReactiveCocoa', '2.1.8' 8 | end 9 | -------------------------------------------------------------------------------- /Example/Tests/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 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Example/Tests/Tests-Prefix.pch: -------------------------------------------------------------------------------- 1 | // The contents of this file are implicitly included at the beginning of every test case source file. 2 | 3 | #ifdef __OBJC__ 4 | 5 | 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /Example/Tests/Tests.m: -------------------------------------------------------------------------------- 1 | // 2 | // HLJNavigationBarTests.m 3 | // HLJNavigationBarTests 4 | // 5 | // Created by bullet_wu on 08/29/2017. 6 | // Copyright (c) 2017 bullet_wu. All rights reserved. 7 | // 8 | 9 | @import XCTest; 10 | 11 | @interface Tests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation Tests 16 | 17 | - (void)setUp 18 | { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown 24 | { 25 | // Put teardown code here. This method is called after the invocation of each test method in the class. 26 | [super tearDown]; 27 | } 28 | 29 | - (void)testExample 30 | { 31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__); 32 | } 33 | 34 | @end 35 | 36 | -------------------------------------------------------------------------------- /Example/Tests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /HLJNavigationBar.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'HLJNavigationBar' 3 | s.version = '1.0.10' 4 | s.summary = '导航栏处理 HLJNavigationBar.' 5 | 6 | s.description = <<-DESC 7 | 完美适配iOS11各种问题 8 | 1.提供2种方法处理导航栏隐藏显示 9 | /* 10 | hlj_prefersNavigationBarHidden ,直接hidden导航栏 11 | hlj_navBarBgAlpha,修改透明度 12 | */ 13 | 2.导航栏颜色可变 14 | 3.导航栏颜色,透明度变化,过渡 15 | 4.自定义返回按钮,不使用leftBarButtonItem 16 | 5.支持 滑动,点击返回事件的回调 17 | /* 18 | - (BOOL)navigationShouldPop; //是否允许触发返 19 | - (void)navigationDidPop;//pop成功 ,因为侧滑返回可能取消 20 | - (void)navigationPopCancel;//侧滑返回取消 21 | */ 22 | 7.支持动态更新切换NavigationItem 23 | DESC 24 | 25 | s.homepage = 'http://pricompany2.hljnbw.cn:3018/iOS_utils/HLJNavigationBar' 26 | s.license = { :type => 'MIT', :file => 'LICENSE' } 27 | s.author = { 'bullet_wu' => 'bullet_wu@163.com' } 28 | s.source = { :git => 'http://pricompany2.hljnbw.cn:3018/iOS_utils/HLJNavigationBar.git', :tag => s.version.to_s } 29 | s.dependency 'ReactiveCocoa', '2.1.8' 30 | 31 | s.ios.deployment_target = '8.0' 32 | s.source_files = 'HLJNavigationBar/Classes/**/*' 33 | end 34 | -------------------------------------------------------------------------------- /HLJNavigationBar/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BulletWu/HLJNavigationBar/cc176040bdb53341f90ba410373d55279dba548a/HLJNavigationBar/Assets/.gitkeep -------------------------------------------------------------------------------- /HLJNavigationBar/Classes/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BulletWu/HLJNavigationBar/cc176040bdb53341f90ba410373d55279dba548a/HLJNavigationBar/Classes/.gitkeep -------------------------------------------------------------------------------- /HLJNavigationBar/Classes/ReplaceMe.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BulletWu/HLJNavigationBar/cc176040bdb53341f90ba410373d55279dba548a/HLJNavigationBar/Classes/ReplaceMe.m -------------------------------------------------------------------------------- /HLJNavigationBar/Classes/UIBarButtonItem+HLJExtend.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIBarButtonItem+HLJExtend.h 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/9/4. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIBarButtonItem (HLJExtend) 12 | 13 | @property (nonatomic ,assign) BOOL hlj_isChangeTintColor; //是否需要更具tintColor 修改按钮颜色 ,默认yes 14 | @property (nonatomic ,strong) UIColor *hlj_tintColor; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /HLJNavigationBar/Classes/UIBarButtonItem+HLJExtend.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIBarButtonItem+HLJExtend.m 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/9/4. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import "UIBarButtonItem+HLJExtend.h" 10 | #import 11 | 12 | @implementation UIBarButtonItem (HLJExtend) 13 | 14 | - (void)setHlj_isChangeTintColor:(BOOL)hlj_isChangeTintColor { 15 | objc_setAssociatedObject(self, @selector(hlj_isChangeTintColor), @(hlj_isChangeTintColor), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 16 | } 17 | 18 | - (BOOL)hlj_isChangeTintColor { 19 | if (objc_getAssociatedObject(self, @selector(hlj_isChangeTintColor))) { 20 | return [objc_getAssociatedObject(self, @selector(hlj_isChangeTintColor)) boolValue]; 21 | } 22 | return YES; 23 | } 24 | 25 | - (void)setHlj_tintColor:(UIColor *)hlj_tintColor { 26 | objc_setAssociatedObject(self, @selector(hlj_tintColor), hlj_tintColor, OBJC_ASSOCIATION_RETAIN); 27 | if (!self.hlj_isChangeTintColor) { 28 | return; 29 | } 30 | if (self.customView) { 31 | if ([self.customView isKindOfClass:[UIImageView class]]) { 32 | self.customView.tintColor = hlj_tintColor; 33 | }else if ([self.customView isKindOfClass:[UILabel class]]) { 34 | UILabel *label = self.customView; 35 | label.textColor = hlj_tintColor; 36 | }else if ([self.customView isKindOfClass:[UIButton class]]) { 37 | UIButton *button = self.customView; 38 | button.tintColor = hlj_tintColor; 39 | if (button.titleLabel) { 40 | [button setTitleColor:hlj_tintColor forState:UIControlStateNormal]; 41 | } 42 | if (button.imageView) { 43 | button.imageView.tintColor = hlj_tintColor; 44 | } 45 | } 46 | return; 47 | } 48 | self.tintColor = hlj_tintColor; 49 | } 50 | 51 | - (UIColor *)hlj_tintColor { 52 | return objc_getAssociatedObject(self, @selector(hlj_tintColor)); 53 | } 54 | 55 | 56 | 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /HLJNavigationBar/Classes/UIColor+HLJNavBarExtend.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+HLJExtend.h 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/9/4. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIColor (HLJNavBarExtend) 12 | 13 | -(CGFloat)hlj_HLJNavBar_alphaComponent; 14 | 15 | +(UIColor *)hlj_HLJNavBar_mixColor1:(UIColor*)color1 color2:(UIColor *)color2 ratio:(CGFloat)ratio; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /HLJNavigationBar/Classes/UIColor+HLJNavBarExtend.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+HLJExtend.m 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/9/4. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import "UIColor+HLJNavBarExtend.h" 10 | 11 | @implementation UIColor (HLJNavBarExtend) 12 | 13 | -(CGFloat)hlj_HLJNavBar_alphaComponent { 14 | UIColor *color = [self hlj_HLJNavBar_colorHandleSpace]; 15 | const CGFloat * components = CGColorGetComponents(color.CGColor); 16 | return components[3]; 17 | } 18 | 19 | +(UIColor *)hlj_HLJNavBar_mixColor1:(UIColor*)color1 color2:(UIColor *)color2 ratio:(CGFloat)ratio { 20 | if(ratio > 1) 21 | ratio = 1; 22 | color1 = [color1 hlj_HLJNavBar_colorHandleSpace]; 23 | color2 = [color2 hlj_HLJNavBar_colorHandleSpace]; 24 | const CGFloat * components1 = CGColorGetComponents(color1.CGColor); 25 | const CGFloat * components2 = CGColorGetComponents(color2.CGColor); 26 | CGFloat r = components1[0]*ratio + components2[0]*(1-ratio); 27 | CGFloat g = components1[1]*ratio + components2[1]*(1-ratio); 28 | CGFloat b = components1[2]*ratio + components2[2]*(1-ratio); 29 | CGFloat alpha = components1[3]*ratio + components2[3]*(1-ratio); 30 | return [UIColor colorWithRed:r green:g blue:b alpha:alpha]; 31 | } 32 | 33 | - (UIColor *)hlj_HLJNavBar_colorHandleSpace { 34 | UIColor *color = self; 35 | if (CGColorGetNumberOfComponents(self.CGColor) < 4) { 36 | if (CGColorSpaceGetModel(CGColorGetColorSpace(color.CGColor)) == kCGColorSpaceModelPattern){ 37 | CGColorSpaceRef rgbColorSpace = CGColorSpaceCreateDeviceRGB(); 38 | unsigned char resultingPixel[4]; 39 | CGContextRef context = CGBitmapContextCreate(&resultingPixel, 1, 1,8,4,rgbColorSpace, kCGImageAlphaNoneSkipLast); 40 | CGContextSetFillColorWithColor(context, [color CGColor]); 41 | CGContextFillRect(context, CGRectMake(0, 0, 1, 1)); 42 | CGContextRelease(context); 43 | CGColorSpaceRelease(rgbColorSpace); 44 | CGFloat R = resultingPixel[0]/255.0; 45 | CGFloat G = resultingPixel[1]/255.0; 46 | CGFloat B = resultingPixel[2]/255.0; 47 | CGFloat alpha = resultingPixel[3]/255.0; 48 | return [UIColor colorWithRed:R 49 | green:G 50 | blue:B 51 | alpha:alpha]; 52 | }else { 53 | const CGFloat *components = CGColorGetComponents(color.CGColor); 54 | return color = [UIColor colorWithRed:components[0] 55 | green:components[0] 56 | blue:components[0] 57 | alpha:components[1]]; 58 | } 59 | 60 | } 61 | 62 | if (CGColorSpaceGetModel(CGColorGetColorSpace(color.CGColor)) != kCGColorSpaceModelRGB) { 63 | return [UIColor whiteColor]; 64 | } 65 | return self; 66 | } 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /HLJNavigationBar/Classes/UIGestureRecognizer+HLJNavBar.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIGestureRecognizer+HLJNavBar.h 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/9/4. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIGestureRecognizer (HLJNavBar) 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HLJNavigationBar/Classes/UIGestureRecognizer+HLJNavBar.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIGestureRecognizer+HLJNavBar.m 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/9/4. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import "UIGestureRecognizer+HLJNavBar.h" 10 | #import 11 | #import "UIViewController+HLJBackHandlerProtocol.h" 12 | #import "UIViewController+HLJNavigationBar.h" 13 | #import "UINavigationController+HLJNavBar.h" 14 | #import "UIImage+HLJNavBarExtend.h" 15 | 16 | static void ExchangedMethod(SEL originalSelector, SEL swizzledSelector, Class class) { 17 | Method originalMethod = class_getInstanceMethod(class, originalSelector); 18 | Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); 19 | BOOL didAddMethod = 20 | class_addMethod(class, 21 | originalSelector, 22 | method_getImplementation(swizzledMethod), 23 | method_getTypeEncoding(swizzledMethod)); 24 | 25 | if (didAddMethod) { 26 | class_replaceMethod(class, 27 | swizzledSelector, 28 | method_getImplementation(originalMethod), 29 | method_getTypeEncoding(originalMethod)); 30 | } 31 | else { 32 | method_exchangeImplementations(originalMethod, swizzledMethod); 33 | } 34 | } 35 | 36 | @interface UIGestureRecognizer () 37 | @property (nonatomic ,weak) id hlj_gestureRecognizerDelegate; 38 | @end 39 | 40 | @implementation UIGestureRecognizer (HLJNavBar) 41 | 42 | + (void)load{ 43 | static dispatch_once_t onceToken; // typedef long dispatch_once_t; 44 | dispatch_once(&onceToken, ^{ 45 | Class class = [self class]; 46 | ExchangedMethod(@selector(setDelegate:), @selector(hlj_HLJNavBar_navSetDelegate:), class); 47 | ExchangedMethod(@selector(respondsToSelector:), @selector(hlj_HLJNavBar_respondsToSelector:), class); 48 | ExchangedMethod(@selector(methodSignatureForSelector:), @selector(hlj_HLJNavBar_methodSignatureForSelector:), class); 49 | ExchangedMethod(@selector(forwardInvocation:), @selector(hlj_HLJNavBar_forwardInvocation:), class); 50 | }); 51 | } 52 | 53 | - (BOOL)hlj_HLJNavBar_respondsToSelector:(SEL)selector { 54 | if ([self hlj_HLJNavBar_respondsToSelector:selector]) { 55 | return YES; 56 | } 57 | if ([self.hlj_gestureRecognizerDelegate respondsToSelector:selector]) { 58 | return YES; 59 | } 60 | return NO; 61 | } 62 | 63 | - (NSMethodSignature *)hlj_HLJNavBar_methodSignatureForSelector:(SEL)selector { 64 | return [self hlj_HLJNavBar_methodSignatureForSelector:selector] ? : [(id)self.hlj_gestureRecognizerDelegate methodSignatureForSelector:selector]; 65 | } 66 | 67 | - (void)hlj_HLJNavBar_forwardInvocation:(NSInvocation *)invocation { 68 | if ([self.hlj_gestureRecognizerDelegate respondsToSelector:invocation.selector]){ 69 | [invocation invokeWithTarget:self.hlj_gestureRecognizerDelegate]; 70 | }else{ 71 | [invocation invokeWithTarget:self]; 72 | } 73 | } 74 | 75 | - (void)hlj_HLJNavBar_navSetDelegate:(id)delegate { 76 | if ([NSStringFromClass([delegate class]) isEqualToString:@"_UINavigationInteractiveTransition"]) { 77 | [self hlj_HLJNavBar_navSetDelegate:delegate?self:nil]; 78 | self.hlj_gestureRecognizerDelegate = delegate != self ? delegate : nil; 79 | }else{ 80 | [self hlj_HLJNavBar_navSetDelegate:delegate]; 81 | } 82 | } 83 | 84 | - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer { 85 | UIViewController *topViewController = [[self class] getCurrentViewController]; 86 | if (topViewController.navigationController.viewControllers.count <= 1 || ![topViewController.navigationController.hlj_currentViewController isEqual:topViewController]) { 87 | return NO; 88 | } 89 | BOOL shouldPop = YES; 90 | if([topViewController respondsToSelector:@selector(navigationShouldPop)]) { 91 | shouldPop = [topViewController navigationShouldPop]; 92 | } 93 | shouldPop = shouldPop && [self.hlj_gestureRecognizerDelegate gestureRecognizerShouldBegin:gestureRecognizer]; 94 | return shouldPop; 95 | } 96 | 97 | #pragma mark - getters and setters 98 | - (void)setHlj_gestureRecognizerDelegate:(id)hlj_gestureRecognizerDelegate { 99 | objc_setAssociatedObject(self, @selector(hlj_gestureRecognizerDelegate), hlj_gestureRecognizerDelegate, OBJC_ASSOCIATION_ASSIGN); 100 | } 101 | 102 | - (id)hlj_gestureRecognizerDelegate { 103 | return objc_getAssociatedObject(self,@selector(hlj_gestureRecognizerDelegate)); 104 | } 105 | 106 | + (UIViewController *)getCurrentViewController{ 107 | UIViewController *result = nil; 108 | UIWindow * window = [[UIApplication sharedApplication] keyWindow]; 109 | if (window.windowLevel != UIWindowLevelNormal){ 110 | NSArray *windows = [[UIApplication sharedApplication] windows]; 111 | for(UIWindow * tmpWin in windows){ 112 | if (tmpWin.windowLevel == UIWindowLevelNormal){ 113 | window = tmpWin; 114 | break; 115 | } 116 | } 117 | } 118 | id nextResponder = nil; 119 | UIViewController *appRootVC=window.rootViewController; 120 | if (appRootVC.presentedViewController) { 121 | nextResponder = appRootVC.presentedViewController; 122 | }else{ 123 | UIView *frontView = [[window subviews] objectAtIndex:0]; 124 | nextResponder = [frontView nextResponder]; 125 | } 126 | if ([nextResponder isKindOfClass:[UITabBarController class]]){ 127 | UITabBarController * tabbar = (UITabBarController *)nextResponder; 128 | UINavigationController * nav = (UINavigationController *)tabbar.viewControllers[tabbar.selectedIndex]; 129 | result=nav.childViewControllers.lastObject; 130 | }else if ([nextResponder isKindOfClass:[UINavigationController class]]){ 131 | UIViewController * nav = (UIViewController *)nextResponder; 132 | result = nav.childViewControllers.lastObject; 133 | }else{ 134 | result = nextResponder; 135 | } 136 | return result; 137 | } 138 | 139 | 140 | @end 141 | 142 | -------------------------------------------------------------------------------- /HLJNavigationBar/Classes/UIImage+HLJNavBarExtend.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+HLJExtend.h 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/8/30. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIImage (HLJNavBarExtend) 12 | 13 | + (UIImage *)hlj_HLJNavBar_imageWithColor:(UIColor *)color alpha:(CGFloat)alpha size:(CGSize)size; 14 | + (UIImage *)hlj_HLJNavBar_imageWithColor:(UIColor *)color; 15 | + (UIImage *)hlj_HLJNavBar_imageWithColor:(UIColor *)color alpha:(CGFloat)alpha; 16 | + (UIImage *)hlj_HLJNavBar_imageByApplyingAlpha:(CGFloat)alpha image:(UIImage*)image; 17 | + (UIImage *)hlj_HLJNavBar_screenImageWithSize:(CGSize )imgSize; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /HLJNavigationBar/Classes/UIImage+HLJNavBarExtend.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+HLJExtend.m 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/8/30. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import "UIImage+HLJNavBarExtend.h" 10 | 11 | @implementation UIImage (HLJNavBarExtend) 12 | 13 | + (UIImage *)hlj_HLJNavBar_imageWithColor:(UIColor *)color alpha:(CGFloat)alpha size:(CGSize)size { 14 | CGRect rect = CGRectMake(0.0f, 0.0f, size.width, size.height); 15 | UIGraphicsBeginImageContext(rect.size); 16 | CGContextRef context = UIGraphicsGetCurrentContext(); 17 | CGContextSetFillColorWithColor(context, [color CGColor]); 18 | CGContextSetAlpha(context, alpha); 19 | CGContextFillRect(context, rect); 20 | UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext(); 21 | UIGraphicsEndImageContext(); 22 | return theImage; 23 | } 24 | 25 | + (UIImage *)hlj_HLJNavBar_imageWithColor:(UIColor *)color { 26 | return [self hlj_HLJNavBar_imageWithColor:color alpha:1.0]; 27 | } 28 | 29 | + (UIImage *)hlj_HLJNavBar_imageWithColor:(UIColor *)color alpha:(CGFloat)alpha { 30 | CGSize size = CGSizeMake(1.0f, 1.0f); 31 | return [self hlj_HLJNavBar_imageWithColor:color alpha:alpha size:size]; 32 | } 33 | 34 | + (UIImage *)hlj_HLJNavBar_imageByApplyingAlpha:(CGFloat)alpha image:(UIImage*)image { 35 | UIGraphicsBeginImageContextWithOptions(image.size, NO, 0.0f); 36 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 37 | CGRect area = CGRectMake(0, 0, image.size.width, image.size.height); 38 | CGContextScaleCTM(ctx, 1, -1); 39 | CGContextTranslateCTM(ctx, 0, -area.size.height); 40 | CGContextSetBlendMode(ctx, kCGBlendModeMultiply); 41 | CGContextSetAlpha(ctx, alpha); 42 | CGContextDrawImage(ctx, area, image.CGImage); 43 | UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); 44 | UIGraphicsEndImageContext(); 45 | return newImage; 46 | } 47 | 48 | 49 | + (UIImage *)hlj_HLJNavBar_screenImageWithSize:(CGSize )imgSize{ 50 | UIGraphicsBeginImageContext(imgSize); 51 | CGContextRef context = UIGraphicsGetCurrentContext(); 52 | UIWindow *window = [[UIApplication sharedApplication].delegate window]; 53 | [window.layer renderInContext:context]; 54 | UIImage * img = UIGraphicsGetImageFromCurrentImageContext(); 55 | UIGraphicsEndImageContext(); 56 | return img; 57 | } 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /HLJNavigationBar/Classes/UINavigationBar+HLJNavigationItem.h: -------------------------------------------------------------------------------- 1 | // 2 | // UINavigationBar+HLJBackItem.h 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/8/30. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import 10 | @interface UINavigationBar (HLJNavigationItem) 11 | 12 | @property (nonatomic ,strong) UIImageView *hlj_backImageView; 13 | 14 | @property (nonatomic ,strong) UIImage *hlj_backImage UI_APPEARANCE_SELECTOR; 15 | @property (nonatomic ,strong) UIColor *hlj_shadowColor UI_APPEARANCE_SELECTOR; 16 | @property (nonatomic ,strong) UIColor *hlj_backgroundColor UI_APPEARANCE_SELECTOR; 17 | @property (nonatomic ,assign) CGFloat hlj_alpha UI_APPEARANCE_SELECTOR; 18 | @property (nonatomic ,strong) UIColor *hlj_barButtonItemTintColor UI_APPEARANCE_SELECTOR; 19 | @property (nonatomic ,strong) UIFont *hlj_barButtonItemFont UI_APPEARANCE_SELECTOR; 20 | @property (nonatomic ,strong) UIColor *hlj_titleColor UI_APPEARANCE_SELECTOR; 21 | @property (nonatomic ,strong) UIFont *hlj_font UI_APPEARANCE_SELECTOR; 22 | 23 | @property (nonatomic ,copy) BOOL (^shouldPopItemBlock) (UINavigationItem *item , UINavigationBar *navigationBar); 24 | @property (nonatomic ,copy) BOOL (^shouldPushItemItemBlock) (UINavigationItem *item , UINavigationBar *navigationBar); 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /HLJNavigationBar/Classes/UINavigationBar+HLJNavigationItem.m: -------------------------------------------------------------------------------- 1 | // 2 | // UINavigationBar+HLJBackItem.m 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/8/30. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import "UINavigationBar+HLJNavigationItem.h" 10 | #import 11 | #import "UINavigationItem+HLJNavigationBar.h" 12 | #import "UIImage+HLJNavBarExtend.h" 13 | #import "UINavigationItem+HLJNavigationBar.h" 14 | #import "UIBarButtonItem+HLJExtend.h" 15 | 16 | static void ExchangedMethod(SEL originalSelector, SEL swizzledSelector, Class class) { 17 | Method originalMethod = class_getInstanceMethod(class, originalSelector); 18 | Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); 19 | BOOL didAddMethod = 20 | class_addMethod(class, 21 | originalSelector, 22 | method_getImplementation(swizzledMethod), 23 | method_getTypeEncoding(swizzledMethod)); 24 | 25 | if (didAddMethod) { 26 | class_replaceMethod(class, 27 | swizzledSelector, 28 | method_getImplementation(originalMethod), 29 | method_getTypeEncoding(originalMethod)); 30 | } 31 | else { 32 | method_exchangeImplementations(originalMethod, swizzledMethod); 33 | } 34 | } 35 | 36 | @interface UINavigationBar () 37 | 38 | @property (nonatomic ,weak) id navDelegate; 39 | 40 | @end 41 | 42 | @implementation UINavigationBar (HLJNavigationItem) 43 | 44 | + (void)load{ 45 | static dispatch_once_t onceToken; 46 | dispatch_once(&onceToken, ^{ 47 | Class class = [self class]; 48 | ExchangedMethod(@selector(layoutSubviews), @selector(hlj_backItemLayoutSubviews), class); 49 | ExchangedMethod(@selector(setTintColor:), @selector(hlj_backItemSetTintColor:), class); 50 | ExchangedMethod(@selector(setDelegate:), @selector(hlj_setDelegate:), class); 51 | ExchangedMethod(@selector(respondsToSelector:), @selector(hlj_respondsToSelector:), class); 52 | ExchangedMethod(@selector(forwardingTargetForSelector:), @selector(hlj_forwardingTargetForSelector:), class); 53 | }); 54 | } 55 | 56 | + (void)initialize { 57 | UINavigationBar * appearance = [UINavigationBar appearance]; 58 | [appearance setBackIndicatorImage:[[UIImage alloc] init]]; 59 | [appearance setBackIndicatorTransitionMaskImage:[[UIImage alloc] init]]; 60 | } 61 | 62 | - (BOOL)hlj_respondsToSelector:(SEL)selector { 63 | if ([self hlj_respondsToSelector:selector]) { 64 | return YES; 65 | } 66 | if ([self.navDelegate respondsToSelector:selector]) { 67 | return YES; 68 | } 69 | return NO; 70 | } 71 | 72 | - (id)hlj_forwardingTargetForSelector:(SEL)aSelector { 73 | if ([self.navDelegate respondsToSelector:aSelector]) { 74 | if ([self hlj_respondsToSelector:aSelector]) { //如果自己原本就能处理 75 | return [self hlj_forwardingTargetForSelector: aSelector]; 76 | } 77 | return self.navDelegate; 78 | } 79 | return [self hlj_forwardingTargetForSelector: aSelector]; 80 | } 81 | 82 | - (void)hlj_setDelegate:(id)delegate { 83 | [self hlj_setDelegate:delegate ? self : nil]; 84 | self.navDelegate = delegate != self ? delegate : nil; 85 | } 86 | 87 | - (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item { 88 | BOOL should = NO; 89 | if (self.shouldPopItemBlock) { 90 | should = self.shouldPopItemBlock(item,navigationBar); 91 | } 92 | if (should) { 93 | if ([self.navDelegate respondsToSelector:@selector(navigationBar:shouldPopItem:)]) { 94 | should = [self.navDelegate navigationBar:navigationBar shouldPopItem:item]; 95 | } 96 | } 97 | return should; 98 | } 99 | 100 | - (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPushItem:(UINavigationItem *)item{ 101 | BOOL should = NO; 102 | if (self.shouldPushItemItemBlock) { 103 | should = self.shouldPushItemItemBlock(item,navigationBar); 104 | } 105 | if (should) { 106 | if ([self.navDelegate respondsToSelector:@selector(navigationBar:shouldPushItem:)]) { 107 | should = [self.navDelegate navigationBar:navigationBar shouldPushItem:item]; 108 | } 109 | } 110 | if(should) { 111 | __weak UINavigationItem *weakItem = item; 112 | item.itemsUpdateBlock = ^(NSArray *itemArray) { 113 | for (UIBarButtonItem *barItem in itemArray) { 114 | if (barItem) { 115 | UIColor *color = nil; 116 | if (weakItem.hlj_barButtonItemTintColor) { 117 | color = weakItem.hlj_barButtonItemTintColor; 118 | }else if (self.hlj_barButtonItemTintColor) { 119 | color = self.hlj_barButtonItemTintColor; 120 | }else { 121 | color = [[UINavigationBar appearance] hlj_barButtonItemTintColor]; 122 | } 123 | barItem.hlj_tintColor = color; 124 | } 125 | } 126 | }; 127 | } 128 | return should; 129 | } 130 | 131 | 132 | - (void)hlj_backItemLayoutSubviews { 133 | [self hlj_backItemLayoutSubviews]; 134 | if (![self showBackItem]) { 135 | self.topItem.hidesBackButton = YES; 136 | self.hlj_backImageView.hidden = YES; 137 | }else { 138 | self.hlj_backImageView.hidden = NO; 139 | } 140 | if (![self.hlj_backImageView isDescendantOfView:self]) { 141 | [self addSubview:self.hlj_backImageView]; 142 | } 143 | for (UIView *view in self.subviews) { 144 | if ([NSStringFromClass([view class]) isEqualToString:@"_UINavigationBarContentView"]) { 145 | for (UIView *subView in view.subviews) { 146 | if ([NSStringFromClass([subView class]) isEqualToString:@"_UIButtonBarButton"]) { 147 | for (UIView *sub_subView in subView.subviews) { 148 | if ([NSStringFromClass([sub_subView class]) isEqualToString:@"_UIBackButtonContainerView"]) { 149 | UIView *backButtonContainerView = sub_subView; 150 | CGRect rect = backButtonContainerView.frame; 151 | rect.size.width = 44.0; 152 | backButtonContainerView.frame = rect; 153 | } 154 | } 155 | } 156 | } 157 | } 158 | } 159 | } 160 | 161 | - (BOOL)showBackItem { 162 | return !(self.topItem.leftBarButtonItem || self.topItem.leftBarButtonItems.count > 0 || [[self.items firstObject] isEqual:self.topItem]); 163 | } 164 | 165 | - (void)hlj_backItemSetTintColor:(UIColor *)tintColor { 166 | [self hlj_backItemSetTintColor:tintColor]; 167 | if (self.hlj_backImageView.image) { 168 | self.hlj_backImageView.tintColor = tintColor; 169 | } 170 | } 171 | 172 | #pragma mark - getters and setters 173 | - (UIImageView *)hlj_backImageView { 174 | if (!objc_getAssociatedObject(self, @selector(hlj_backImageView))) { 175 | UIImage *image = [[UINavigationBar appearance] hlj_backImage]; 176 | UIImageView *backImageV = [[UIImageView alloc] initWithFrame:CGRectMake(13.5, 6, image.size.width, 30)]; 177 | backImageV.contentMode = UIViewContentModeCenter; 178 | backImageV.image = image; 179 | backImageV.alpha = 0; 180 | objc_setAssociatedObject(self, @selector(hlj_backImageView), backImageV, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 181 | } 182 | return objc_getAssociatedObject(self, @selector(hlj_backImageView)); 183 | } 184 | 185 | - (void)setHlj_backImageView:(UIImageView *)hlj_backImageView { 186 | objc_setAssociatedObject(self, @selector(hlj_backImageView), hlj_backImageView, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 187 | } 188 | 189 | - (UIImage *)hlj_backImage { 190 | return objc_getAssociatedObject(self, @selector(hlj_backImage)); 191 | } 192 | 193 | - (void)setHlj_backImage:(UIImage *)hlj_backImage { 194 | objc_setAssociatedObject(self, @selector(hlj_backImage), hlj_backImage, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 195 | } 196 | 197 | - (UIColor *)hlj_shadowColor { 198 | return objc_getAssociatedObject(self, @selector(hlj_shadowColor)); 199 | } 200 | 201 | - (void)setHlj_shadowColor:(UIColor *)hlj_shadowColor { 202 | if (!hlj_shadowColor) { 203 | return; 204 | } 205 | if (CGColorEqualToColor(hlj_shadowColor.CGColor, self.hlj_shadowColor.CGColor)) { 206 | return; 207 | } 208 | objc_setAssociatedObject(self, @selector(hlj_shadowColor), hlj_shadowColor, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 209 | UINavigationBar *navBarAppearance = [UINavigationBar appearance]; 210 | UIImage *shadowImage = [UIImage hlj_HLJNavBar_imageWithColor:[self hlj_shadowColor] alpha:1 size:CGSizeMake(1/[UIScreen mainScreen].scale, 1/[UIScreen mainScreen].scale)]; 211 | [navBarAppearance setShadowImage:shadowImage]; 212 | } 213 | 214 | - (UIColor *)hlj_backgroundColor { 215 | return objc_getAssociatedObject(self, @selector(hlj_backgroundColor)); 216 | } 217 | 218 | - (void)setHlj_backgroundColor:(UIColor *)hlj_backgroundColor { 219 | if (!hlj_backgroundColor) { 220 | return; 221 | } 222 | if (CGColorEqualToColor(hlj_backgroundColor.CGColor, self.hlj_backgroundColor.CGColor)) { 223 | return; 224 | } 225 | objc_setAssociatedObject(self, @selector(hlj_backgroundColor), hlj_backgroundColor, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 226 | [self setSystemBackgroundColor:hlj_backgroundColor]; 227 | } 228 | 229 | - (void)setSystemBackgroundColor:(UIColor *)color { 230 | UINavigationBar *navBarAppearance = [UINavigationBar appearance]; 231 | UIImage *image = [[UIImage hlj_HLJNavBar_imageWithColor:color alpha:1] stretchableImageWithLeftCapWidth:2 topCapHeight:64]; 232 | [navBarAppearance setBackgroundImage:image forBarMetrics:UIBarMetricsDefault]; 233 | } 234 | 235 | - (CGFloat)hlj_alpha { 236 | if (objc_getAssociatedObject(self, @selector(hlj_alpha))) { 237 | return [objc_getAssociatedObject(self, @selector(hlj_alpha)) floatValue]; 238 | } 239 | return -1; 240 | } 241 | 242 | - (void)setHlj_alpha:(CGFloat)hlj_alpha { 243 | objc_setAssociatedObject(self, @selector(hlj_alpha), @(hlj_alpha), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 244 | } 245 | 246 | - (UIColor *)hlj_barButtonItemTintColor { 247 | return objc_getAssociatedObject(self, @selector(hlj_barButtonItemTintColor)); 248 | } 249 | 250 | - (void)setHlj_barButtonItemTintColor:(UIColor *)hlj_barButtonItemTintColor { 251 | if (!hlj_barButtonItemTintColor) { 252 | return; 253 | } 254 | if (CGColorEqualToColor(hlj_barButtonItemTintColor.CGColor, self.hlj_barButtonItemTintColor.CGColor)) { 255 | return; 256 | } 257 | objc_setAssociatedObject(self, @selector(hlj_barButtonItemTintColor), hlj_barButtonItemTintColor, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 258 | UIBarButtonItem *appearance = [UIBarButtonItem appearance]; 259 | appearance.tintColor = hlj_barButtonItemTintColor; 260 | } 261 | 262 | - (UIFont *)hlj_barButtonItemFont { 263 | return objc_getAssociatedObject(self, @selector(hlj_barButtonItemFont)); 264 | } 265 | 266 | - (void)setHlj_barButtonItemFont:(UIFont *)hlj_barButtonItemFont { 267 | if (!hlj_barButtonItemFont) { 268 | return; 269 | } 270 | if ([hlj_barButtonItemFont isEqual:self.hlj_barButtonItemFont]) { 271 | return; 272 | } 273 | objc_setAssociatedObject(self, @selector(hlj_barButtonItemFont), hlj_barButtonItemFont, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 274 | UIBarButtonItem *appearance = [UIBarButtonItem appearance]; 275 | [appearance setTitleTextAttributes:@{NSFontAttributeName: hlj_barButtonItemFont} forState:UIControlStateNormal]; 276 | [appearance setTitleTextAttributes:@{NSFontAttributeName: hlj_barButtonItemFont} forState:UIControlStateHighlighted]; 277 | } 278 | 279 | - (UIColor *)hlj_titleColor { 280 | return objc_getAssociatedObject(self, @selector(hlj_titleColor)); 281 | } 282 | 283 | - (void)setHlj_titleColor:(UIColor *)hlj_titleColor { 284 | if (!hlj_titleColor) { 285 | return; 286 | } 287 | if (CGColorEqualToColor(hlj_titleColor.CGColor, self.hlj_titleColor.CGColor)) { 288 | return; 289 | } 290 | objc_setAssociatedObject(self, @selector(hlj_titleColor), hlj_titleColor, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 291 | UINavigationBar *navBarAppearance = [UINavigationBar appearance]; 292 | NSMutableDictionary *titleTextAttributes = [NSMutableDictionary dictionaryWithDictionary:navBarAppearance.titleTextAttributes]; 293 | titleTextAttributes[NSForegroundColorAttributeName] = hlj_titleColor; 294 | [navBarAppearance setTitleTextAttributes:titleTextAttributes]; 295 | } 296 | 297 | - (UIFont *)hlj_font { 298 | return objc_getAssociatedObject(self, @selector(hlj_font)); 299 | } 300 | 301 | - (void)setHlj_font:(UIFont *)hlj_font { 302 | if (!hlj_font) { 303 | return; 304 | } 305 | if ([hlj_font isEqual:self.hlj_font]) { 306 | return; 307 | } 308 | objc_setAssociatedObject(self, @selector(hlj_font), hlj_font, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 309 | UINavigationBar *navBarAppearance = [UINavigationBar appearance]; 310 | NSMutableDictionary *titleTextAttributes = [NSMutableDictionary dictionaryWithDictionary:navBarAppearance.titleTextAttributes]; 311 | titleTextAttributes[NSFontAttributeName] = hlj_font; 312 | [navBarAppearance setTitleTextAttributes:titleTextAttributes]; 313 | } 314 | 315 | - (id)navDelegate { 316 | id delegate = objc_getAssociatedObject(self, @selector(navDelegate)); 317 | return delegate; 318 | } 319 | 320 | - (void)setNavDelegate:(id)navDelegate { 321 | objc_setAssociatedObject(self, @selector(navDelegate), navDelegate, OBJC_ASSOCIATION_ASSIGN); 322 | } 323 | 324 | - (void)setShouldPopItemBlock:(BOOL (^)(UINavigationItem *, UINavigationBar *))shouldPopItemBlock { 325 | objc_setAssociatedObject(self, @selector(shouldPopItemBlock),shouldPopItemBlock, OBJC_ASSOCIATION_COPY_NONATOMIC); 326 | } 327 | 328 | - (BOOL (^)(UINavigationItem *, UINavigationBar *))shouldPopItemBlock { 329 | return objc_getAssociatedObject(self, @selector(shouldPopItemBlock)); 330 | } 331 | 332 | - (void)setShouldPushItemItemBlock:(BOOL (^)(UINavigationItem *, UINavigationBar *))shouldPushItemItemBlock { 333 | objc_setAssociatedObject(self, @selector(shouldPushItemItemBlock), shouldPushItemItemBlock, OBJC_ASSOCIATION_COPY_NONATOMIC); 334 | } 335 | 336 | - (BOOL (^)(UINavigationItem *, UINavigationBar *))shouldPushItemItemBlock { 337 | return objc_getAssociatedObject(self, @selector(shouldPushItemItemBlock)); 338 | } 339 | 340 | @end 341 | -------------------------------------------------------------------------------- /HLJNavigationBar/Classes/UINavigationController+HLJNavBar.h: -------------------------------------------------------------------------------- 1 | // 2 | // UINavigationController+HLJNavBar.h 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/8/29. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UINavigationController (HLJNavBar) 12 | 13 | - (void)hlj_setNeedsNavigationItemStyleWithViewController:(UIViewController *)viewController; 14 | - (void)hlj_setNeedsNavigationBackgroundColor:(UIColor *)color; 15 | 16 | @property (nonatomic ,assign) BOOL hlj_viewControllerBasedNavigationBarAppearanceEnabled; 17 | @property (nonatomic ,weak) UIViewController *hlj_currentViewController; 18 | 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /HLJNavigationBar/Classes/UINavigationController+HLJNavBar.m: -------------------------------------------------------------------------------- 1 | // 2 | // UINavigationController+HLJNavBar.m 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/8/29. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import "UINavigationController+HLJNavBar.h" 10 | #import "UIViewController+HLJNavigationBar.h" 11 | #import 12 | #import "UIImage+HLJNavBarExtend.h" 13 | #import "UINavigationBar+HLJNavigationItem.h" 14 | #import "UIColor+HLJNavBarExtend.h" 15 | #import "UIViewController+HLJBackHandlerProtocol.h" 16 | #import "UINavigationItem+HLJNavigationBar.h" 17 | #import "UIBarButtonItem+HLJExtend.h" 18 | static void ExchangedMethod(SEL originalSelector, SEL swizzledSelector, Class class) { 19 | Method originalMethod = class_getInstanceMethod(class, originalSelector); 20 | Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); 21 | BOOL didAddMethod = 22 | class_addMethod(class, 23 | originalSelector, 24 | method_getImplementation(swizzledMethod), 25 | method_getTypeEncoding(swizzledMethod)); 26 | 27 | if (didAddMethod) { 28 | class_replaceMethod(class, 29 | swizzledSelector, 30 | method_getImplementation(originalMethod), 31 | method_getTypeEncoding(originalMethod)); 32 | } 33 | else { 34 | method_exchangeImplementations(originalMethod, swizzledMethod); 35 | } 36 | } 37 | 38 | 39 | typedef void (^HLJViewControllerWillAppearInjectBlock)(UIViewController *viewController, BOOL animated); 40 | 41 | @interface UIViewController (NavigationBarHiddenPrivate) 42 | @property (nonatomic, copy) HLJViewControllerWillAppearInjectBlock hlj_willAppearInjectBlock; 43 | @end 44 | 45 | @implementation UIViewController (NavigationBarHiddenPrivate) 46 | 47 | + (void)load{ 48 | static dispatch_once_t onceToken; 49 | dispatch_once(&onceToken, ^{ 50 | Class class = [self class]; 51 | ExchangedMethod(@selector(viewWillAppear:), @selector(hlj_viewWillAppear:), class); 52 | }); 53 | } 54 | 55 | - (void)hlj_viewWillAppear:(BOOL)animated{ 56 | if ([NSStringFromClass([self class]) hasPrefix:@"DS"]) { 57 | [self hlj_viewWillAppear:animated]; 58 | return; 59 | } 60 | if (self.hlj_willAppearInjectBlock) { 61 | self.hlj_willAppearInjectBlock(self, animated); 62 | } 63 | [self hlj_viewWillAppear:animated]; 64 | } 65 | 66 | - (HLJViewControllerWillAppearInjectBlock)hlj_willAppearInjectBlock { 67 | return objc_getAssociatedObject(self, _cmd); 68 | } 69 | 70 | - (void)setHlj_willAppearInjectBlock:(HLJViewControllerWillAppearInjectBlock)block { 71 | objc_setAssociatedObject(self, @selector(hlj_willAppearInjectBlock), block, OBJC_ASSOCIATION_COPY_NONATOMIC); 72 | } 73 | 74 | @end 75 | 76 | @interface UINavigationController () 77 | 78 | @property (nonatomic ,weak) id navDelegate; 79 | 80 | @end 81 | 82 | @implementation UINavigationController (HLJNavBar) 83 | 84 | + (void)load{ 85 | static dispatch_once_t onceToken; 86 | dispatch_once(&onceToken, ^{ 87 | Class class = [self class]; 88 | ExchangedMethod(@selector(pushViewController:animated:), @selector(hlj_pushViewController:animated:), class); 89 | ExchangedMethod(NSSelectorFromString(@"_updateInteractiveTransition:"), @selector(hlj_updateInteractiveTransition:), class); 90 | ExchangedMethod(@selector(viewDidLoad), @selector(hlj_navBarViewDidLoad), class); 91 | ExchangedMethod(@selector(setDelegate:), @selector(hlj_navSetDelegate:), class); 92 | ExchangedMethod(@selector(respondsToSelector:), @selector(hlj_respondsToSelector:), class); 93 | ExchangedMethod(@selector(methodSignatureForSelector:), @selector(hlj_methodSignatureForSelector:), class); 94 | ExchangedMethod(@selector(forwardInvocation:), @selector(hlj_forwardInvocation:), class); 95 | ExchangedMethod(@selector(popToViewController:animated:), @selector(hlj_popToViewController:animated:), class); 96 | ExchangedMethod(@selector(popToRootViewControllerAnimated:), @selector(hlj_popToRootViewControllerAnimated:), class); 97 | ExchangedMethod(@selector(popViewControllerAnimated:), @selector(hlj_popViewControllerAnimated:), class); 98 | }); 99 | } 100 | 101 | - (void)hlj_navBarViewDidLoad{ 102 | [self hlj_navBarViewDidLoad]; 103 | if (self.delegate != self) { 104 | if (self.delegate == nil) { 105 | self.delegate = self; 106 | }else { 107 | self.delegate = self.delegate; 108 | } 109 | } 110 | __weak UINavigationController *bself = self; 111 | self.navigationBar.shouldPopItemBlock = ^BOOL(UINavigationItem *item, UINavigationBar *navigationBar) { 112 | return [bself hlj_navigationBar:navigationBar shouldPopItem:item]; 113 | }; 114 | self.navigationBar.shouldPushItemItemBlock = ^BOOL(UINavigationItem *item, UINavigationBar *navigationBar) { 115 | return [bself hlj_navigationBar:navigationBar shouldPushItem:item]; 116 | }; 117 | } 118 | 119 | - (void)hlj_pushViewController:(UIViewController *)viewController animated:(BOOL)animated { 120 | if (self.viewControllers.count > 0) { 121 | viewController.hidesBottomBarWhenPushed = YES; 122 | } 123 | self.navigationBar.translucent = NO; 124 | [self hlj_setupViewControllerBasedNavigationBarAppearanceIfNeeded:viewController]; 125 | [self hlj_pushViewController:viewController animated:animated]; 126 | } 127 | 128 | - (void)hlj_setupViewControllerBasedNavigationBarAppearanceIfNeeded:(UIViewController *)appearingViewController { 129 | __weak UINavigationController * bself = self; 130 | HLJViewControllerWillAppearInjectBlock block = ^(UIViewController *viewController, BOOL animated) { 131 | if (viewController.hlj_prefersNavigationBarHidden) { 132 | bself.hlj_viewControllerBasedNavigationBarAppearanceEnabled = YES; 133 | } 134 | if (bself.hlj_viewControllerBasedNavigationBarAppearanceEnabled) { 135 | [bself setNavigationBarHidden:viewController.hlj_prefersNavigationBarHidden animated:animated]; 136 | } 137 | void (^once)() = ^{ 138 | if (objc_getAssociatedObject(viewController, _cmd)) { 139 | return; 140 | }else{ 141 | objc_setAssociatedObject(viewController, _cmd, @"navbar_once", OBJC_ASSOCIATION_RETAIN); 142 | dispatch_async(dispatch_get_main_queue(), ^{ 143 | [bself updateNavBarStyleWithViewController:viewController]; 144 | }); 145 | } 146 | }; 147 | once(); 148 | }; 149 | appearingViewController.hlj_willAppearInjectBlock = block; 150 | UIViewController *disappearingViewController = self.viewControllers.lastObject; 151 | if (disappearingViewController && !disappearingViewController.hlj_willAppearInjectBlock) { 152 | disappearingViewController.hlj_willAppearInjectBlock = block; 153 | } 154 | } 155 | 156 | - (void)hlj_updateInteractiveTransition:(CGFloat)percentComplete{ 157 | UIViewController *topVC = self.topViewController; 158 | id coor = topVC.transitionCoordinator; 159 | if (!coor) { 160 | [self hlj_updateInteractiveTransition:percentComplete]; 161 | return; 162 | } 163 | UIViewController *fromVC = [coor viewControllerForKey:UITransitionContextFromViewControllerKey]; 164 | UIViewController *toVC = [coor viewControllerForKey:UITransitionContextToViewControllerKey]; 165 | if (toVC.hlj_prefersNavigationBarHidden) { 166 | [self hlj_updateInteractiveTransition:percentComplete]; 167 | return; 168 | } 169 | UIColor *toColor = [toVC hlj_navBarBackgroundColor]; 170 | UIColor *fromColor = [fromVC hlj_navBarBackgroundColor]; 171 | if (fromVC.hlj_prefersNavigationBarHidden) { 172 | fromColor = nil; 173 | } 174 | BOOL toHidesBack = [toVC isEqual:[self.viewControllers firstObject]] || toVC.navigationItem.hidesBackButton; 175 | if (toHidesBack) { 176 | CGFloat hideBack= 1 - percentComplete; 177 | self.navigationBar.hlj_backImageView.alpha = hideBack; 178 | }else{ 179 | CGFloat hideBack= 2 * ABS(0.5 - percentComplete); 180 | self.navigationBar.hlj_backImageView.alpha = hideBack; 181 | } 182 | 183 | if (!CGColorEqualToColor(toColor.CGColor,fromColor.CGColor)) { 184 | UIColor *mixColor = [UIColor hlj_HLJNavBar_mixColor1:toColor color2:fromColor ratio:percentComplete]; 185 | [self setNeedsNavigationBackgroundColor:mixColor]; 186 | } 187 | 188 | UIColor *fromVCTintColor = [fromVC hlj_barButtonItemTintColor]; 189 | if (fromVC.hlj_prefersNavigationBarHidden) { 190 | fromVCTintColor = nil; 191 | } 192 | UIColor *toVCTintColor = [toVC hlj_barButtonItemTintColor]; 193 | if (!CGColorEqualToColor(fromVCTintColor.CGColor,toVCTintColor.CGColor)) { 194 | UIColor *mixColor = [UIColor hlj_HLJNavBar_mixColor1:toVCTintColor color2:fromVCTintColor ratio:percentComplete]; 195 | [self setNeedsNavigationItemBarButtonItemStyleWithViewController:fromVC tintColor:mixColor font:[toVC hlj_barButtonItemFont]]; 196 | } 197 | UIColor *fromVCTitleColor = [fromVC hlj_navBarTitleColor]; 198 | if (fromVC.hlj_prefersNavigationBarHidden) { 199 | fromVCTitleColor = nil; 200 | } 201 | UIColor *toVCTitleColor = [toVC hlj_navBarTitleColor]; 202 | if (!CGColorEqualToColor(fromVCTitleColor.CGColor,toVCTitleColor.CGColor)) { 203 | UIColor *mixColor = [UIColor hlj_HLJNavBar_mixColor1:toVCTitleColor color2:fromVCTitleColor ratio:percentComplete]; 204 | [self setNeedsNavigationBarTitleColor:mixColor font:[toVC hlj_navBarTitleFont]]; 205 | } 206 | [self hlj_updateInteractiveTransition:percentComplete]; 207 | } 208 | 209 | 210 | - (BOOL)hlj_respondsToSelector:(SEL)selector { 211 | 212 | if ([self hlj_respondsToSelector:selector]) { 213 | return YES; 214 | } 215 | if ([self.navDelegate respondsToSelector:selector]) { 216 | return YES; 217 | } 218 | return NO; 219 | } 220 | 221 | - (NSMethodSignature *)hlj_methodSignatureForSelector:(SEL)selector { 222 | return [self hlj_methodSignatureForSelector:selector] ? : [(id)self.navDelegate methodSignatureForSelector:selector]; 223 | } 224 | 225 | - (void)hlj_forwardInvocation:(NSInvocation *)invocation { 226 | if ([self.navDelegate respondsToSelector:invocation.selector]){ 227 | [invocation invokeWithTarget:self.navDelegate]; 228 | }else{ 229 | [invocation invokeWithTarget:self]; 230 | } 231 | } 232 | 233 | - (void)hlj_navSetDelegate:(id)delegate { 234 | [self hlj_navSetDelegate:delegate?self:nil]; 235 | self.navDelegate = delegate != self ? delegate : nil; 236 | } 237 | 238 | 239 | - (NSArray<__kindof UIViewController *> *)hlj_popToViewController:(UIViewController *)viewController animated:(BOOL)animated { 240 | self.navigationBar.translucent = NO; 241 | [self.viewControllers enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { 242 | if ([obj isEqual:viewController]) { 243 | *stop = YES; 244 | }else{ 245 | [self didPopViewController:obj]; 246 | } 247 | }]; 248 | [self updateNavBarStyleWithViewController:viewController]; 249 | return [self hlj_popToViewController:viewController animated:animated]; 250 | } 251 | 252 | - (NSArray<__kindof UIViewController *> *)hlj_popToRootViewControllerAnimated:(BOOL)animated { 253 | self.navigationBar.translucent = NO; 254 | [self.viewControllers enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { 255 | if ([obj isEqual:[self.viewControllers firstObject]]) { 256 | *stop = YES; 257 | }else{ 258 | [self didPopViewController:obj]; 259 | } 260 | }]; 261 | [self updateNavBarStyleWithViewController:[self.viewControllers firstObject]]; 262 | return [self hlj_popToRootViewControllerAnimated:animated]; 263 | } 264 | 265 | - (UIViewController *)hlj_popViewControllerAnimated:(BOOL)animated { 266 | if (self.viewControllers.count >= 2) { 267 | UIViewController *viewController = [self.viewControllers objectAtIndex:self.viewControllers.count - 2]; 268 | if([viewController hlj_navBarBgAlpha] >= 1) { 269 | self.navigationBar.translucent = NO; 270 | } 271 | UIGestureRecognizer *gestureRecognizer = self.interactivePopGestureRecognizer; 272 | if (gestureRecognizer.state != UIGestureRecognizerStateBegan) { //非手势触发的,一般为点击了其它位置或者是执行一段代码之后程序调用popViewControllerAnimated 273 | [self updateNavBarStyleWithViewController:viewController]; 274 | [self didPopViewController:self.topViewController]; 275 | }else{//侧滑返回 276 | } 277 | } 278 | return [self hlj_popViewControllerAnimated:animated]; 279 | } 280 | 281 | #pragma mark - public methods 282 | - (void)hlj_setNeedsNavigationItemStyleWithViewController:(UIViewController *)viewController { 283 | [self updateNavBarStyleWithViewController:viewController]; 284 | } 285 | 286 | #pragma mark UINavigationControllerDelegate 287 | - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{ 288 | 289 | if (self.navDelegate && [self.navDelegate respondsToSelector:@selector(navigationController:willShowViewController:animated:)]) { 290 | [self.navDelegate navigationController:navigationController willShowViewController:viewController animated:animated]; 291 | } 292 | if (![viewController.navigationItem.backBarButtonItem.title isEqualToString:@""]) { 293 | viewController.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] 294 | initWithTitle:@"" 295 | style:UIBarButtonItemStylePlain 296 | target:nil 297 | action:nil]; 298 | 299 | } 300 | UIViewController *topVC = self.topViewController; 301 | id coor = topVC.transitionCoordinator; 302 | if (!coor) { 303 | return; 304 | } 305 | NSString *version = [UIDevice currentDevice].systemVersion; 306 | if (version.doubleValue >= 10.0) { 307 | [coor notifyWhenInteractionChangesUsingBlock:^(id context) { 308 | [self dealInteractionChanges:context]; 309 | }]; 310 | }else{ 311 | [coor notifyWhenInteractionEndsUsingBlock:^(id context) { 312 | [self dealInteractionChanges:context]; 313 | }]; 314 | } 315 | } 316 | 317 | - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated { 318 | self.hlj_currentViewController = viewController; 319 | if (self.navDelegate && [self.navDelegate respondsToSelector:@selector(navigationController:didShowViewController:animated:)]) { 320 | [self.navDelegate navigationController:navigationController didShowViewController:viewController animated:animated]; 321 | } 322 | } 323 | 324 | #pragma mark - private methods 325 | - (BOOL)hlj_navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item { 326 | UIViewController *topVC = self.topViewController; 327 | if (self.viewControllers.count != self.navigationBar.items.count) { 328 | return YES; 329 | } 330 | BOOL shouldPop = YES; 331 | if([topVC respondsToSelector:@selector(navigationShouldPop)]) { 332 | shouldPop = [topVC navigationShouldPop]; 333 | } 334 | if (shouldPop) { 335 | id coor = topVC.transitionCoordinator; 336 | if (coor && coor.initiallyInteractive) { 337 | return YES; 338 | } 339 | NSInteger itemCount = self.navigationBar.items.count; 340 | NSInteger n = self.viewControllers.count >= itemCount ? 2 : 1; 341 | if (self.viewControllers.count > self.viewControllers.count - n) { 342 | UIViewController *popToVC = self.viewControllers[self.viewControllers.count - n]; 343 | [self popToViewController:popToVC animated:YES]; 344 | } 345 | return YES; 346 | }else{ 347 | for(UIView *subview in [navigationBar subviews]) { 348 | if(0. < subview.alpha && subview.alpha < 1.) { 349 | [UIView animateWithDuration:.25 animations:^{ 350 | subview.alpha = 1.; 351 | }]; 352 | } 353 | } 354 | return NO; 355 | } 356 | return YES; 357 | } 358 | 359 | - (BOOL)hlj_navigationBar:(UINavigationBar *)navigationBar shouldPushItem:(UINavigationItem *)item{ 360 | [self updateNavBarStyleWithViewController:self.topViewController]; 361 | return YES; 362 | } 363 | 364 | - (void)dealInteractionChanges:(id)context { 365 | if ([context isCancelled]) { 366 | UIViewController *fromVC = [context viewControllerForKey:UITransitionContextFromViewControllerKey]; 367 | if ([fromVC respondsToSelector:@selector(navigationPopCancel)]) { 368 | [fromVC navigationPopCancel]; 369 | } 370 | CGFloat cancellDuration = context.transitionDuration * context.percentComplete; 371 | [UIView animateWithDuration:cancellDuration animations:^{ 372 | [self updateNavBarStyleWithViewController:fromVC]; 373 | }]; 374 | }else{ 375 | UIViewController *fromVC = [context viewControllerForKey:UITransitionContextFromViewControllerKey]; 376 | [self didPopViewController:fromVC]; 377 | CGFloat finishDuration = context.transitionDuration * (1 - context.percentComplete); 378 | UIViewController *toVC = [context viewControllerForKey:UITransitionContextToViewControllerKey]; 379 | [UIView animateWithDuration:finishDuration animations:^{ 380 | [self updateNavBarStyleWithViewController:toVC]; 381 | }]; 382 | } 383 | } 384 | 385 | - (void)updateNavBarStyleWithViewController:(UIViewController *)viewController { 386 | if ([NSStringFromClass([self.topViewController class]) isEqualToString:@"UPWebController"]) { 387 | [self.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault]; 388 | return; 389 | } 390 | if (viewController.hlj_prefersNavigationBarHidden) { 391 | return; 392 | } 393 | BOOL hidesBack = [[self.viewControllers firstObject] isEqual:viewController] || viewController.navigationItem.hidesBackButton; 394 | self.navigationBar.hlj_backImageView.alpha = !hidesBack; 395 | self.navigationBar.shadowImage = [UIImage hlj_HLJNavBar_imageWithColor:[viewController hlj_navBarShadowColor] alpha:1 size:CGSizeMake(1/[[UIScreen mainScreen] scale], 1/[[UIScreen mainScreen] scale])]; 396 | [self setNeedsNavigationBackgroundColor:[viewController hlj_navBarBackgroundColor]]; 397 | [self setNeedsNavigationItemBarButtonItemStyleWithViewController:viewController]; 398 | [self setNeedsNavigationBarTitleColor:[viewController hlj_navBarTitleColor] font:[viewController hlj_navBarTitleFont]]; 399 | } 400 | 401 | - (void)hlj_setNeedsNavigationBackgroundColor:(UIColor *)color { 402 | [self setNeedsNavigationBackgroundColor:color]; 403 | } 404 | 405 | - (void)setNeedsNavigationBackgroundColor:(UIColor *)color{ 406 | CGFloat alpha = 0.0; 407 | [color getRed:nil green:nil blue:nil alpha:&alpha]; 408 | if (alpha < 1) { 409 | self.navigationBar.translucent = YES; 410 | }else { 411 | self.navigationBar.translucent = NO; 412 | } 413 | UIImage *image = [[UIImage hlj_HLJNavBar_imageWithColor:color] stretchableImageWithLeftCapWidth:2 topCapHeight:64]; 414 | for (UIView *view in self.navigationBar.subviews) { 415 | if ([NSStringFromClass([view class]) isEqualToString:@"_UIBarBackground"]) { 416 | for (UIView *subView in view.subviews) { 417 | if ([subView isKindOfClass:[UIImageView class]]) { 418 | UIImageView*imageView = (UIImageView *)subView; 419 | imageView.image = image; 420 | } 421 | } 422 | } 423 | } 424 | [self.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault]; 425 | } 426 | 427 | - (void)setNeedsNavigationItemBarButtonItemStyleWithViewController:(UIViewController *)viewController { 428 | [self setNeedsNavigationItemBarButtonItemStyleWithViewController:viewController tintColor:[viewController hlj_barButtonItemTintColor] font:[viewController hlj_barButtonItemFont]]; 429 | } 430 | 431 | - (void)setNeedsNavigationItemBarButtonItemStyleWithViewController:(UIViewController *)viewController tintColor:(UIColor *)tintColor font:(UIFont *)font{ 432 | for (UIBarButtonItem *item in viewController.navigationItem.rightBarButtonItems) { 433 | item.hlj_tintColor = tintColor; 434 | [item setTitleTextAttributes:@{NSFontAttributeName: font} forState:UIControlStateNormal]; 435 | [item setTitleTextAttributes:@{NSFontAttributeName: font} forState:UIControlStateHighlighted]; 436 | } 437 | for (UIBarButtonItem *item in viewController.navigationItem.leftBarButtonItems) { 438 | item.hlj_tintColor = tintColor; 439 | [item setTitleTextAttributes:@{NSFontAttributeName: font} forState:UIControlStateNormal]; 440 | [item setTitleTextAttributes:@{NSFontAttributeName: font} forState:UIControlStateHighlighted]; 441 | } 442 | viewController.navigationItem.leftBarButtonItem.hlj_tintColor = tintColor; 443 | [viewController.navigationItem.leftBarButtonItem setTitleTextAttributes:@{NSFontAttributeName:font} forState:UIControlStateNormal]; 444 | [viewController.navigationItem.leftBarButtonItem setTitleTextAttributes:@{NSFontAttributeName:font} forState:UIControlStateHighlighted]; 445 | viewController.navigationItem.rightBarButtonItem.hlj_tintColor = tintColor; 446 | [viewController.navigationItem.rightBarButtonItem setTitleTextAttributes:@{NSFontAttributeName: font} forState:UIControlStateNormal]; 447 | [viewController.navigationItem.rightBarButtonItem setTitleTextAttributes:@{NSFontAttributeName:font} forState:UIControlStateHighlighted]; 448 | self.navigationBar.hlj_backImageView.tintColor = tintColor; 449 | } 450 | 451 | - (void)setNeedsNavigationBarTitleColor:(UIColor *)color font:(UIFont *)font{ 452 | NSMutableDictionary *titleTextAttributes = [NSMutableDictionary dictionaryWithDictionary:self.navigationBar.titleTextAttributes]; 453 | titleTextAttributes[NSForegroundColorAttributeName] = color; 454 | titleTextAttributes[NSFontAttributeName] = font; 455 | self.navigationBar.titleTextAttributes = titleTextAttributes; 456 | } 457 | 458 | - (void)didPopViewController:(UIViewController *)viewController { 459 | if ([viewController respondsToSelector:@selector(navigationDidPop)]) { 460 | [viewController navigationDidPop]; 461 | } 462 | } 463 | 464 | 465 | #pragma mark UIGestureRecognizerDelegate 466 | - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer { 467 | if (gestureRecognizer == self.interactivePopGestureRecognizer) { 468 | return (self.viewControllers.count > 1); 469 | } 470 | return YES; 471 | } 472 | 473 | - (id)navDelegate { 474 | return objc_getAssociatedObject(self, @selector(navDelegate)); 475 | } 476 | 477 | - (void)setNavDelegate:(id)navDelegate { 478 | objc_setAssociatedObject(self, @selector(navDelegate), navDelegate, OBJC_ASSOCIATION_ASSIGN); 479 | } 480 | 481 | - (BOOL)hlj_viewControllerBasedNavigationBarAppearanceEnabled { 482 | NSNumber *number = objc_getAssociatedObject(self, _cmd); 483 | if (number) { 484 | return number.boolValue; 485 | } 486 | self.hlj_viewControllerBasedNavigationBarAppearanceEnabled = NO; 487 | return NO; 488 | } 489 | 490 | - (void)setHlj_viewControllerBasedNavigationBarAppearanceEnabled:(BOOL)hlj_viewControllerBasedNavigationBarAppearanceEnabled { 491 | SEL key = @selector(hlj_viewControllerBasedNavigationBarAppearanceEnabled); 492 | objc_setAssociatedObject(self, key, @(hlj_viewControllerBasedNavigationBarAppearanceEnabled), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 493 | } 494 | 495 | - (UIViewController *)hlj_currentViewController { 496 | return objc_getAssociatedObject(self, @selector(hlj_currentViewController)); 497 | } 498 | 499 | - (void)setHlj_currentViewController:(UIViewController *)hlj_currentViewController { 500 | objc_setAssociatedObject(self, @selector(hlj_currentViewController), hlj_currentViewController, OBJC_ASSOCIATION_ASSIGN); 501 | } 502 | 503 | @end 504 | -------------------------------------------------------------------------------- /HLJNavigationBar/Classes/UINavigationItem+HLJFixSpace.h: -------------------------------------------------------------------------------- 1 | // 2 | // HLJWebBrowserDebugViewController.h 3 | // HLJWebBrowser 4 | // 5 | // Created by 项元智 on 2017/9/26. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UINavigationItem (HLJFixSpace) 12 | 13 | @property(nonatomic, strong) NSNumber *hlj_privateLeftSpace; 14 | @property(nonatomic, strong) NSNumber *hlj_privateRightSpace; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /HLJNavigationBar/Classes/UINavigationItem+HLJFixSpace.m: -------------------------------------------------------------------------------- 1 | // 2 | // HLJWebBrowserDebugViewController.h 3 | // HLJWebBrowser 4 | // 5 | // Created by 项元智 on 2017/9/26. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import "UINavigationItem+HLJFixSpace.h" 10 | #import 11 | #import 12 | 13 | static void ExchangedMethod(SEL originalSelector, SEL swizzledSelector, Class class) { 14 | Method originalMethod = class_getInstanceMethod(class, originalSelector); 15 | Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); 16 | BOOL didAddMethod = 17 | class_addMethod(class, 18 | originalSelector, 19 | method_getImplementation(swizzledMethod), 20 | method_getTypeEncoding(swizzledMethod)); 21 | 22 | if (didAddMethod) { 23 | class_replaceMethod(class, 24 | swizzledSelector, 25 | method_getImplementation(originalMethod), 26 | method_getTypeEncoding(originalMethod)); 27 | } 28 | else { 29 | method_exchangeImplementations(originalMethod, swizzledMethod); 30 | } 31 | } 32 | 33 | @implementation UINavigationItem (HLJFixSpace) 34 | 35 | + (void)load{ 36 | static dispatch_once_t onceToken; 37 | dispatch_once(&onceToken, ^{ 38 | Class class = [self class]; 39 | ExchangedMethod(@selector(setLeftBarButtonItems:), @selector(hlj_UINavigationItemFixSpace_setLeftBarButtonItems:), class); 40 | ExchangedMethod(@selector(setRightBarButtonItems:), @selector(hlj_UINavigationItemFixSpace_setRightBarButtonItems:), class); 41 | }); 42 | } 43 | 44 | -(void)hlj_UINavigationItemFixSpace_setLeftBarButtonItems:(NSArray *)leftBarButtonItems { 45 | 46 | if (@available(iOS 11.0, *)) { 47 | UIBarButtonItem *firstItem = leftBarButtonItems.firstObject; 48 | UIBarButtonSystemItem systemItem; 49 | CGFloat width; 50 | @try { 51 | systemItem = [[firstItem valueForKey:@"systemItem"] integerValue]; 52 | width = [[firstItem valueForKey:@"width"] floatValue]; 53 | }@catch(NSException *ex) { 54 | } 55 | 56 | if(systemItem == UIBarButtonSystemItemFixedSpace && width < 0) { 57 | self.hlj_privateLeftSpace = @(width + 8 + 8); 58 | NSMutableArray *array = [NSMutableArray arrayWithArray:leftBarButtonItems]; 59 | [array removeObjectAtIndex:0]; 60 | [self hlj_UINavigationItemFixSpace_setLeftBarButtonItems:array]; 61 | return; 62 | } 63 | } 64 | self.hlj_privateLeftSpace = nil; 65 | [self hlj_UINavigationItemFixSpace_setLeftBarButtonItems:leftBarButtonItems]; 66 | } 67 | 68 | -(void)hlj_UINavigationItemFixSpace_setRightBarButtonItems:(NSArray *)rightBarButtonItems { 69 | if (@available(iOS 11.0, *)) { 70 | UIBarButtonItem *firstItem = rightBarButtonItems.firstObject; 71 | UIBarButtonSystemItem systemItem; 72 | CGFloat width; 73 | @try { 74 | systemItem = [[firstItem valueForKey:@"systemItem"] integerValue]; 75 | width = [[firstItem valueForKey:@"width"] floatValue]; 76 | }@catch(NSException *ex) { 77 | } 78 | if(systemItem == UIBarButtonSystemItemFixedSpace && width < 0) { 79 | self.hlj_privateRightSpace = @(width + 8 + 8); 80 | NSMutableArray *array = [NSMutableArray arrayWithArray:rightBarButtonItems]; 81 | [array removeObjectAtIndex:0]; 82 | [self hlj_UINavigationItemFixSpace_setRightBarButtonItems:array]; 83 | return; 84 | } 85 | } 86 | self.hlj_privateRightSpace = nil; 87 | [self hlj_UINavigationItemFixSpace_setRightBarButtonItems:rightBarButtonItems]; 88 | } 89 | 90 | #pragma mark -- setters & getters 91 | -(void)setHlj_privateLeftSpace:(NSNumber *)hlj_privateLeftSpace { 92 | objc_setAssociatedObject(self, @selector(hlj_privateLeftSpace), hlj_privateLeftSpace, OBJC_ASSOCIATION_RETAIN); 93 | } 94 | 95 | -(NSNumber *)hlj_privateLeftSpace { 96 | return objc_getAssociatedObject(self, @selector(hlj_privateLeftSpace)); 97 | } 98 | 99 | -(void)setHlj_privateRightSpace:(NSNumber *)hlj_privateRightSpace { 100 | objc_setAssociatedObject(self, @selector(hlj_privateRightSpace), hlj_privateRightSpace, OBJC_ASSOCIATION_RETAIN); 101 | } 102 | 103 | -(NSNumber *)hlj_privateRightSpace { 104 | return objc_getAssociatedObject(self, @selector(hlj_privateRightSpace)); 105 | } 106 | 107 | @end 108 | -------------------------------------------------------------------------------- /HLJNavigationBar/Classes/UINavigationItem+HLJNavigationBar.h: -------------------------------------------------------------------------------- 1 | // 2 | // UINavigationItem+HLJNavigationBar.h 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/9/5. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UINavigationItem (HLJNavigationBar) 12 | 13 | @property (nonatomic ,strong) UIColor *hlj_navBarShadowColor; // 导航栏分割线图片 14 | @property (nonatomic ,strong) UIColor *hlj_navBarBackgroundColor; //导航栏背景颜色 15 | @property (nonatomic ,assign) CGFloat hlj_navBarBgAlpha; //透明度 16 | @property (nonatomic ,strong) UIColor *hlj_barButtonItemTintColor; //导航栏按钮颜色 17 | @property (nonatomic ,strong) UIFont *hlj_barButtonItemFont; //导航栏按钮字体大小 18 | @property (nonatomic ,strong) UIColor *hlj_navBarTitleColor; //导航栏title字体颜色 19 | @property (nonatomic ,strong) UIFont *hlj_navBarTitleFont; //导航栏title字体 20 | 21 | @property (nonatomic ,copy) void (^itemsUpdateBlock) (NSArray *itemArray); 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /HLJNavigationBar/Classes/UINavigationItem+HLJNavigationBar.m: -------------------------------------------------------------------------------- 1 | // 2 | // UINavigationItem+HLJNavigationBar.m 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/9/5. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import "UINavigationItem+HLJNavigationBar.h" 10 | #import 11 | #import "UIImage+HLJNavBarExtend.h" 12 | #import "UINavigationBar+HLJNavigationItem.h" 13 | #import "UIBarButtonItem+HLJExtend.h" 14 | 15 | static void ExchangedMethod(SEL originalSelector, SEL swizzledSelector, Class class) { 16 | Method originalMethod = class_getInstanceMethod(class, originalSelector); 17 | Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); 18 | BOOL didAddMethod = 19 | class_addMethod(class, 20 | originalSelector, 21 | method_getImplementation(swizzledMethod), 22 | method_getTypeEncoding(swizzledMethod)); 23 | 24 | if (didAddMethod) { 25 | class_replaceMethod(class, 26 | swizzledSelector, 27 | method_getImplementation(originalMethod), 28 | method_getTypeEncoding(originalMethod)); 29 | } 30 | else { 31 | method_exchangeImplementations(originalMethod, swizzledMethod); 32 | } 33 | } 34 | 35 | 36 | @implementation UINavigationItem (HLJNavigationBar) 37 | 38 | + (void)load{ 39 | static dispatch_once_t onceToken; 40 | dispatch_once(&onceToken, ^{ 41 | Class class = [self class]; 42 | ExchangedMethod(@selector(setRightBarButtonItem:), @selector(hlj_HLJNavigationBar_setRightBarButtonItem:), class); 43 | ExchangedMethod(@selector(setLeftBarButtonItem:), @selector(hlj_HLJNavigationBar_setLeftBarButtonItem:), class); 44 | ExchangedMethod(@selector(setRightBarButtonItems:), @selector(hlj_HLJNavigationBar_setRightBarButtonItems:), class); 45 | ExchangedMethod(@selector(setLeftBarButtonItems:), @selector(hlj_HLJNavigationBar_setLeftBarButtonItems:), class); 46 | 47 | 48 | }); 49 | } 50 | 51 | - (void)hlj_HLJNavigationBar_setRightBarButtonItem:(UIBarButtonItem *)rightBarButtonItem { 52 | [self hlj_HLJNavigationBar_setRightBarButtonItem:rightBarButtonItem]; 53 | if (rightBarButtonItem) { 54 | if (self.itemsUpdateBlock) { 55 | self.itemsUpdateBlock(@[rightBarButtonItem]); 56 | } 57 | } 58 | } 59 | 60 | - (void)hlj_HLJNavigationBar_setLeftBarButtonItem:(UIBarButtonItem *)leftBarButtonItem { 61 | [self hlj_HLJNavigationBar_setLeftBarButtonItem:leftBarButtonItem]; 62 | if (leftBarButtonItem) { 63 | if (self.itemsUpdateBlock) { 64 | self.itemsUpdateBlock(@[leftBarButtonItem]); 65 | } 66 | } 67 | } 68 | 69 | - (void)hlj_HLJNavigationBar_setRightBarButtonItems:(NSArray *)rightBarButtonItems { 70 | [self hlj_HLJNavigationBar_setRightBarButtonItems:rightBarButtonItems]; 71 | if (rightBarButtonItems && rightBarButtonItems.count > 0) { 72 | if (self.itemsUpdateBlock) { 73 | self.itemsUpdateBlock(rightBarButtonItems); 74 | } 75 | } 76 | } 77 | 78 | - (void)hlj_HLJNavigationBar_setLeftBarButtonItems:(NSArray *)leftBarButtonItems { 79 | [self hlj_HLJNavigationBar_setLeftBarButtonItems:leftBarButtonItems]; 80 | if (leftBarButtonItems && leftBarButtonItems.count > 0) { 81 | if (self.itemsUpdateBlock) { 82 | self.itemsUpdateBlock(leftBarButtonItems); 83 | } 84 | } 85 | } 86 | 87 | 88 | - (UIColor *)hlj_navBarShadowColor { 89 | return objc_getAssociatedObject(self, @selector(hlj_navBarShadowColor)); 90 | } 91 | 92 | - (void)setHlj_navBarShadowColor:(UIColor *)hlj_navBarShadowColor { 93 | objc_setAssociatedObject(self, @selector(hlj_navBarShadowColor), hlj_navBarShadowColor, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 94 | } 95 | 96 | - (UIColor *)hlj_navBarBackgroundColor { 97 | return objc_getAssociatedObject(self, @selector(hlj_navBarBackgroundColor)); 98 | } 99 | 100 | - (void)setHlj_navBarBackgroundColor:(UIColor *)hlj_navBarBackgroundColor { 101 | objc_setAssociatedObject(self, @selector(hlj_navBarBackgroundColor), hlj_navBarBackgroundColor, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 102 | } 103 | 104 | - (CGFloat)hlj_navBarBgAlpha { 105 | if (objc_getAssociatedObject(self, @selector(hlj_navBarBgAlpha))) { 106 | return [objc_getAssociatedObject(self, @selector(hlj_navBarBgAlpha)) floatValue]; 107 | } 108 | return -1; 109 | } 110 | 111 | - (void)setHlj_navBarBgAlpha:(CGFloat)hlj_navBarBgAlpha { 112 | if (hlj_navBarBgAlpha <= 0) { 113 | hlj_navBarBgAlpha = 0; 114 | } 115 | objc_setAssociatedObject(self, @selector(hlj_navBarBgAlpha), @(hlj_navBarBgAlpha), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 116 | } 117 | 118 | - (UIColor *)hlj_barButtonItemTintColor { 119 | return objc_getAssociatedObject(self, @selector(hlj_barButtonItemTintColor)); 120 | } 121 | 122 | - (void)setHlj_barButtonItemTintColor :(UIColor *)hlj_barButtonItemTintColor { 123 | objc_setAssociatedObject(self, @selector(hlj_barButtonItemTintColor), hlj_barButtonItemTintColor , OBJC_ASSOCIATION_RETAIN_NONATOMIC); 124 | } 125 | 126 | - (UIFont *)hlj_barButtonItemFont { 127 | return objc_getAssociatedObject(self, @selector(hlj_barButtonItemFont)); 128 | } 129 | 130 | - (void)setHlj_barButtonItemFont:(UIFont *)hlj_barButtonItemFont { 131 | objc_setAssociatedObject(self, @selector(hlj_barButtonItemFont), hlj_barButtonItemFont, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 132 | } 133 | 134 | - (UIColor *)hlj_navBarTitleColor { 135 | return objc_getAssociatedObject(self, @selector(hlj_navBarTitleColor)); 136 | } 137 | 138 | - (void)setHlj_navBarTitleColor:(UIColor *)hlj_navBarTitleColor { 139 | objc_setAssociatedObject(self, @selector(hlj_navBarTitleColor), hlj_navBarTitleColor, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 140 | } 141 | 142 | - (UIFont *)hlj_navBarTitleFont { 143 | return objc_getAssociatedObject(self, @selector(hlj_navBarTitleFont)); 144 | } 145 | 146 | - (void)setHlj_navBarTitleFont:(UIFont *)hlj_navBarTitleFont { 147 | objc_setAssociatedObject(self, @selector(hlj_navBarTitleFont), hlj_navBarTitleFont, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 148 | } 149 | 150 | - (void)setItemsUpdateBlock:(void (^)(NSArray *))itemsUpdateBlock { 151 | objc_setAssociatedObject(self, @selector(itemsUpdateBlock), itemsUpdateBlock, OBJC_ASSOCIATION_COPY_NONATOMIC); 152 | } 153 | 154 | - (void (^)(NSArray *))itemsUpdateBlock { 155 | return objc_getAssociatedObject(self, @selector(itemsUpdateBlock)); 156 | } 157 | 158 | 159 | @end 160 | -------------------------------------------------------------------------------- /HLJNavigationBar/Classes/UIStackView+HLJFixSpace.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIStackView+HLJFixSpace.h 3 | // HLJNavigationBar 4 | // 5 | // Created by 项元智 on 2017/9/28. 6 | // 7 | 8 | #import 9 | 10 | @interface UIStackView (HLJFixSpace) 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /HLJNavigationBar/Classes/UIStackView+HLJFixSpace.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIStackView+HLJFixSpace.m 3 | // HLJNavigationBar 4 | // 5 | // Created by 项元智 on 2017/9/28. 6 | // 7 | 8 | #import "UIStackView+HLJFixSpace.h" 9 | #import "UINavigationItem+HLJFixSpace.h" 10 | #import 11 | 12 | static void ExchangedMethod(SEL originalSelector, SEL swizzledSelector, Class class) { 13 | Method originalMethod = class_getInstanceMethod(class, originalSelector); 14 | Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); 15 | BOOL didAddMethod = 16 | class_addMethod(class, 17 | originalSelector, 18 | method_getImplementation(swizzledMethod), 19 | method_getTypeEncoding(swizzledMethod)); 20 | 21 | if (didAddMethod) { 22 | class_replaceMethod(class, 23 | swizzledSelector, 24 | method_getImplementation(originalMethod), 25 | method_getTypeEncoding(originalMethod)); 26 | } 27 | else { 28 | method_exchangeImplementations(originalMethod, swizzledMethod); 29 | } 30 | } 31 | 32 | @interface UIStackView() 33 | @property(nonatomic, weak) NSLayoutConstraint *hlj_addedConstraint; 34 | @end 35 | 36 | @implementation UIStackView (HLJFixSpace) 37 | 38 | + (void)load{ 39 | static dispatch_once_t onceToken; 40 | dispatch_once(&onceToken, ^{ 41 | Class class = [self class]; 42 | ExchangedMethod(@selector(layoutSubviews), @selector(hlj_UIStackViewFixSpace_layoutSubviews), class); 43 | }); 44 | } 45 | 46 | -(UINavigationBar*)checkNavigationBar { 47 | 48 | UIView *view = self; 49 | while (![view isKindOfClass:UINavigationBar.class] && view.superview) { 50 | view = [view superview]; 51 | } 52 | 53 | if([view isKindOfClass:UINavigationBar.class]) { 54 | return (UINavigationBar*)view; 55 | } 56 | 57 | return nil; 58 | } 59 | 60 | -(void)hlj_UIStackViewFixSpace_layoutSubviews { 61 | [self hlj_UIStackViewFixSpace_layoutSubviews]; 62 | 63 | UINavigationBar *navigationBar = [self checkNavigationBar]; 64 | 65 | if(navigationBar == nil) 66 | return; 67 | 68 | UINavigationItem *item = navigationBar.topItem; 69 | 70 | if(self.frame.origin.x<100) { 71 | 72 | // 左边 73 | if(self.hlj_addedConstraint && (item.hlj_privateLeftSpace == nil || self.hlj_addedConstraint.constant != item.hlj_privateLeftSpace.floatValue)) { 74 | [self.superview removeConstraint:self.hlj_addedConstraint]; 75 | self.hlj_addedConstraint = nil; 76 | } 77 | 78 | if(self.hlj_addedConstraint == nil && item.hlj_privateLeftSpace) { 79 | 80 | NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:self 81 | attribute:NSLayoutAttributeLeading 82 | relatedBy:NSLayoutRelationEqual 83 | toItem:self.superview 84 | attribute:NSLayoutAttributeLeading 85 | multiplier:1.0 86 | constant:item.hlj_privateLeftSpace.floatValue]; 87 | [self.superview addConstraint:constraint]; 88 | self.hlj_addedConstraint = constraint; 89 | } 90 | 91 | } else if(self.frame.origin.x+self.frame.size.width > navigationBar.bounds.size.width-100) { 92 | 93 | // 右边 94 | if(self.hlj_addedConstraint && (item.hlj_privateRightSpace == nil || self.hlj_addedConstraint.constant != -item.hlj_privateRightSpace.floatValue)) { 95 | [self.superview removeConstraint:self.hlj_addedConstraint]; 96 | self.hlj_addedConstraint = nil; 97 | } 98 | 99 | if(self.hlj_addedConstraint == nil && item.hlj_privateRightSpace) { 100 | 101 | NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:self 102 | attribute:NSLayoutAttributeTrailing 103 | relatedBy:NSLayoutRelationEqual 104 | toItem:self.superview 105 | attribute:NSLayoutAttributeTrailing 106 | multiplier:1.0 107 | constant:-item.hlj_privateRightSpace.floatValue]; 108 | [self.superview addConstraint:constraint]; 109 | self.hlj_addedConstraint = constraint; 110 | } 111 | 112 | } 113 | } 114 | 115 | -(void)setHlj_addedConstraint:(NSLayoutConstraint *)hlj_addedConstraint { 116 | 117 | id __weak weakObject = hlj_addedConstraint; 118 | id (^block)() = ^{return weakObject;}; 119 | objc_setAssociatedObject(self, @selector(hlj_addedConstraint), block, OBJC_ASSOCIATION_COPY_NONATOMIC); 120 | } 121 | 122 | -(NSLayoutConstraint *)hlj_addedConstraint { 123 | 124 | id (^block)() = objc_getAssociatedObject(self, @selector(hlj_addedConstraint)); 125 | return block ? block() : nil; 126 | } 127 | 128 | @end 129 | -------------------------------------------------------------------------------- /HLJNavigationBar/Classes/UIView+HLJIntrinsicContentSize.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+HLJIntrinsicContentSize.h 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/9/13. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIView (HLJIntrinsicContentSize) 12 | 13 | @property(nonatomic, assign) CGSize hlj_intrinsicContentSize; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /HLJNavigationBar/Classes/UIView+HLJIntrinsicContentSize.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+HLJIntrinsicContentSize.m 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/9/13. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import "UIView+HLJIntrinsicContentSize.h" 10 | #import 11 | 12 | static void ExchangedMethod(SEL originalSelector, SEL swizzledSelector, Class class) { 13 | Method originalMethod = class_getInstanceMethod(class, originalSelector); 14 | Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); 15 | BOOL didAddMethod = 16 | class_addMethod(class, 17 | originalSelector, 18 | method_getImplementation(swizzledMethod), 19 | method_getTypeEncoding(swizzledMethod)); 20 | 21 | if (didAddMethod) { 22 | class_replaceMethod(class, 23 | swizzledSelector, 24 | method_getImplementation(originalMethod), 25 | method_getTypeEncoding(originalMethod)); 26 | } 27 | else { 28 | method_exchangeImplementations(originalMethod, swizzledMethod); 29 | } 30 | } 31 | 32 | @implementation UIView (HLJIntrinsicContentSize) 33 | 34 | + (void)load{ 35 | static dispatch_once_t onceToken; 36 | dispatch_once(&onceToken, ^{ 37 | Class class = [self class]; 38 | if (@available(iOS 11.0, *)) { 39 | ExchangedMethod(@selector(intrinsicContentSize), @selector(hlj_HLJIntrinsicContentSize_intrinsicContentSize), class); 40 | } 41 | }); 42 | } 43 | 44 | //UILayoutFittingCompressedSize: 返回合适的最小大小。 45 | //UILayoutFittingExpandedSize: 返回合适的最大大小。 46 | - (CGSize)hlj_HLJIntrinsicContentSize_intrinsicContentSize { 47 | if (!CGSizeEqualToSize(self.hlj_intrinsicContentSize, CGSizeZero)) { 48 | return self.hlj_intrinsicContentSize; //UILayoutFittingExpandedSize 49 | } 50 | return [self hlj_HLJIntrinsicContentSize_intrinsicContentSize]; 51 | } 52 | 53 | - (CGSize)hlj_intrinsicContentSize { 54 | return [objc_getAssociatedObject(self, @selector(hlj_intrinsicContentSize)) CGSizeValue]; 55 | } 56 | 57 | - (void)setHlj_intrinsicContentSize:(CGSize)hlj_intrinsicContentSize { 58 | objc_setAssociatedObject(self, @selector(hlj_intrinsicContentSize), @(hlj_intrinsicContentSize), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 59 | } 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /HLJNavigationBar/Classes/UIViewController+HLJBackHandlerProtocol.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+HLJBackHandlerProtocol.h 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/8/30. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol HLJBackHandlerProtocol 12 | @optional 13 | - (BOOL)navigationShouldPop; //是否允许触发返 14 | - (void)navigationDidPop;//pop成功 ,因为侧滑返回可能取消 15 | - (void)navigationPopCancel;//侧滑返回取消 16 | @end 17 | 18 | @interface UIViewController (HLJBackHandlerProtocol) 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /HLJNavigationBar/Classes/UIViewController+HLJBackHandlerProtocol.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+HLJBackHandlerProtocol.m 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/8/30. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import "UIViewController+HLJBackHandlerProtocol.h" 10 | 11 | @implementation UIViewController (HLJBackHandlerProtocol) 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HLJNavigationBar/Classes/UIViewController+HLJNavigationBar.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+HLJNavigationBar.h 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/8/29. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | #define adjustsScrollViewInsets_NO(scrollView,vc)\ 13 | do { \ 14 | _Pragma("clang diagnostic push") \ 15 | _Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \ 16 | if ([UIScrollView instancesRespondToSelector:NSSelectorFromString(@"setContentInsetAdjustmentBehavior:")]) {\ 17 | [scrollView performSelector:NSSelectorFromString(@"setContentInsetAdjustmentBehavior:") withObject:@(2)];\ 18 | } else {\ 19 | vc.automaticallyAdjustsScrollViewInsets = NO;\ 20 | }\ 21 | _Pragma("clang diagnostic pop") \ 22 | } while (0) 23 | 24 | @interface UIViewController (HLJNavigationBar) 25 | 26 | @property (nonatomic ,assign) BOOL hlj_prefersNavigationBarHidden;//隐藏导航栏 27 | 28 | - (UIColor *)hlj_navBarShadowColor; 29 | - (UIColor *)hlj_navBarBackgroundColor; 30 | - (CGFloat)hlj_navBarBgAlpha; 31 | - (UIColor *)hlj_barButtonItemTintColor; 32 | - (UIFont *)hlj_barButtonItemFont; 33 | - (UIColor *)hlj_navBarTitleColor; 34 | - (UIFont *)hlj_navBarTitleFont; 35 | 36 | - (void)hlj_setNeedsNavigationItemLayout; 37 | //- (void)hlj_replaceNavigationItem:(UINavigationItem *)navigationItem completeBlock:(void(^)())completeBlock; 38 | @end 39 | -------------------------------------------------------------------------------- /HLJNavigationBar/Classes/UIViewController+HLJNavigationBar.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+HLJNavigationBar.m 3 | // HLJNavigationBar_Example 4 | // 5 | // Created by 吴晓辉 on 2017/8/29. 6 | // Copyright © 2017年 bullet_wu. All rights reserved. 7 | // 8 | 9 | #import "UIViewController+HLJNavigationBar.h" 10 | #import 11 | #import "UIImage+HLJNavBarExtend.h" 12 | #import "UIColor+HLJNavBarExtend.h" 13 | #import "UINavigationController+HLJNavBar.h" 14 | #import "UINavigationBar+HLJNavigationItem.h" 15 | #import "UINavigationItem+HLJNavigationBar.h" 16 | #import 17 | #import 18 | 19 | static void ExchangedMethod(SEL originalSelector, SEL swizzledSelector, Class class) { 20 | Method originalMethod = class_getInstanceMethod(class, originalSelector); 21 | Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); 22 | BOOL didAddMethod = 23 | class_addMethod(class, 24 | originalSelector, 25 | method_getImplementation(swizzledMethod), 26 | method_getTypeEncoding(swizzledMethod)); 27 | 28 | if (didAddMethod) { 29 | class_replaceMethod(class, 30 | swizzledSelector, 31 | method_getImplementation(originalMethod), 32 | method_getTypeEncoding(originalMethod)); 33 | } 34 | else { 35 | method_exchangeImplementations(originalMethod, swizzledMethod); 36 | } 37 | } 38 | 39 | 40 | @interface UIViewController () 41 | @property (nonatomic ,strong) UIColor *hlj_private_navBarShadowColor; 42 | @property (nonatomic ,strong) UIColor *hlj_private_navBarBackgroundColor; 43 | @property (nonatomic ,assign) CGFloat hlj_private_navBarBgAlpha; 44 | @property (nonatomic ,strong) UIColor *hlj_private_barButtonItemTintColor; 45 | @property (nonatomic ,strong) UIFont *hlj_private_barButtonItemFont; 46 | @property (nonatomic ,strong) UIColor *hlj_private_navBarTitleColor; 47 | @property (nonatomic ,strong) UIFont *hlj_private_navBarTitleFont; 48 | 49 | @end 50 | 51 | @implementation UIViewController (HLJNavigationBar) 52 | 53 | + (void)load{ 54 | static dispatch_once_t onceToken; 55 | dispatch_once(&onceToken, ^{ 56 | Class class = [self class]; 57 | ExchangedMethod(@selector(presentViewController:animated:completion:), @selector(hlj_presentViewController:animated:completion:), class); 58 | }); 59 | } 60 | 61 | - (void)hlj_presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion { 62 | if ([viewControllerToPresent isKindOfClass:[UINavigationController class]]) { 63 | UINavigationController *nav = nil; 64 | if ([self isKindOfClass:[UINavigationController class]]) { 65 | nav = (UINavigationController *)self; 66 | }else { 67 | nav = self.navigationController; 68 | } 69 | UINavigationController *nowNav = (UINavigationController *)viewControllerToPresent; 70 | if (!nowNav.navigationBar.hlj_backgroundColor) { 71 | nowNav.navigationBar.hlj_backgroundColor = nav.navigationBar.hlj_backgroundColor; 72 | } 73 | if (nowNav.navigationBar.hlj_shadowColor) { 74 | nowNav.navigationBar.hlj_shadowColor = nav.navigationBar.hlj_shadowColor; 75 | } 76 | if (nowNav.navigationBar.hlj_titleColor) { 77 | nowNav.navigationBar.hlj_titleColor = nav.navigationBar.hlj_titleColor; 78 | } 79 | if (nowNav.navigationBar.hlj_font) { 80 | nowNav.navigationBar.hlj_font = nav.navigationBar.hlj_font; 81 | } 82 | if (nowNav.navigationBar.hlj_barButtonItemTintColor) { 83 | nowNav.navigationBar.hlj_barButtonItemTintColor = nav.navigationBar.hlj_barButtonItemTintColor; 84 | } 85 | if (nowNav.navigationBar.hlj_barButtonItemFont) { 86 | nowNav.navigationBar.hlj_barButtonItemFont = nav.navigationBar.hlj_barButtonItemFont; 87 | } 88 | } 89 | [self hlj_presentViewController:viewControllerToPresent animated:flag completion:completion]; 90 | } 91 | 92 | 93 | - (void)hlj_setNeedsNavigationItemLayout { 94 | UIViewController *viewController = self; 95 | while (viewController.parentViewController) { 96 | UIViewController *parentViewController = viewController.parentViewController; 97 | if ([parentViewController isEqual:self.navigationController]) { 98 | break; 99 | } 100 | viewController = viewController.parentViewController; 101 | } 102 | if ([self.navigationController.topViewController isEqual:viewController]) { 103 | [self.navigationController hlj_setNeedsNavigationItemStyleWithViewController:self]; 104 | } 105 | } 106 | 107 | - (BOOL)hlj_prefersNavigationBarHidden { 108 | return [objc_getAssociatedObject(self, @selector(hlj_prefersNavigationBarHidden)) boolValue]; 109 | } 110 | 111 | - (void)setHlj_prefersNavigationBarHidden:(BOOL)hlj_prefersNavigationBarHidden { 112 | objc_setAssociatedObject(self, @selector(hlj_prefersNavigationBarHidden), @(hlj_prefersNavigationBarHidden), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 113 | } 114 | 115 | - (UINavigationItem *)hlj_newNavigationItem { 116 | return objc_getAssociatedObject(self, @selector(hlj_newNavigationItem)); 117 | } 118 | 119 | - (void)setHlj_newNavigationItem:(UINavigationItem *)hlj_newNavigationItem { 120 | objc_setAssociatedObject(self, @selector(hlj_newNavigationItem), hlj_newNavigationItem, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 121 | } 122 | 123 | - (UIColor *)hlj_navBarShadowColor { 124 | UIColor *color = nil; 125 | if (self.navigationItem.hlj_navBarShadowColor) { 126 | color = self.navigationItem.hlj_navBarShadowColor; 127 | }else if (self.navigationController.navigationBar.hlj_shadowColor) { 128 | color = self.navigationController.navigationBar.hlj_shadowColor; 129 | if (!self.navigationController && self.hlj_private_navBarShadowColor) { 130 | color = self.hlj_private_navBarShadowColor; 131 | } 132 | }else { 133 | color = [[UINavigationBar appearance] hlj_shadowColor]; 134 | if (!self.navigationController && self.hlj_private_navBarShadowColor) { 135 | color = self.hlj_private_navBarShadowColor; 136 | } 137 | } 138 | 139 | self.hlj_private_navBarShadowColor = color; 140 | 141 | 142 | return [color colorWithAlphaComponent:[self hlj_navBarBgAlpha] * [color hlj_HLJNavBar_alphaComponent]]; 143 | } 144 | 145 | - (UIColor *)hlj_navBarBackgroundColor { 146 | UIColor *color = nil; 147 | if (self.navigationItem.hlj_navBarBackgroundColor) { 148 | color = self.navigationItem.hlj_navBarBackgroundColor; 149 | }else if (self.navigationController.navigationBar.hlj_backgroundColor) { 150 | color = self.navigationController.navigationBar.hlj_backgroundColor; 151 | if (!self.navigationController && self.hlj_private_navBarBackgroundColor) { 152 | color = self.hlj_private_navBarBackgroundColor; 153 | } 154 | }else { 155 | color = [[UINavigationBar appearance] hlj_backgroundColor]; 156 | if (!self.navigationController && self.hlj_private_navBarBackgroundColor) { 157 | color = self.hlj_private_navBarBackgroundColor; 158 | } 159 | } 160 | self.hlj_private_navBarBackgroundColor = color; 161 | return [color colorWithAlphaComponent:[self hlj_navBarBgAlpha]]; 162 | } 163 | 164 | - (CGFloat)hlj_navBarBgAlpha { 165 | CGFloat alpha = 0; 166 | if (self.navigationItem.hlj_navBarBgAlpha >= 0) { 167 | alpha = self.navigationItem.hlj_navBarBgAlpha; 168 | }else if (self.navigationController.navigationBar.hlj_alpha >= 0) { 169 | alpha = self.navigationController.navigationBar.hlj_alpha; 170 | if (!self.navigationController && self.hlj_private_navBarBgAlpha >= 0) { 171 | alpha = self.hlj_private_navBarBgAlpha; 172 | } 173 | }else { 174 | alpha = [[UINavigationBar appearance] hlj_alpha]; 175 | if (!self.navigationController && self.hlj_private_navBarBgAlpha >= 0) { 176 | alpha = self.hlj_private_navBarBgAlpha; 177 | } 178 | } 179 | self.hlj_private_navBarBgAlpha = alpha; 180 | return alpha; 181 | } 182 | 183 | - (UIColor *)hlj_barButtonItemTintColor { 184 | UIColor *color = nil; 185 | if (self.navigationItem.hlj_barButtonItemTintColor) { 186 | color = self.navigationItem.hlj_barButtonItemTintColor; 187 | }else if (self.navigationController.navigationBar.hlj_barButtonItemTintColor) { 188 | color = self.navigationController.navigationBar.hlj_barButtonItemTintColor; 189 | if (!self.navigationController && self.hlj_private_barButtonItemTintColor) { 190 | color = self.hlj_private_barButtonItemTintColor; 191 | } 192 | }else { 193 | color = [[UINavigationBar appearance] hlj_barButtonItemTintColor]; 194 | if (!self.navigationController && self.hlj_private_barButtonItemTintColor) { 195 | color = self.hlj_private_barButtonItemTintColor; 196 | } 197 | } 198 | 199 | self.hlj_private_barButtonItemTintColor = color; 200 | return color; 201 | } 202 | 203 | - (UIFont *)hlj_barButtonItemFont { 204 | UIFont *font = nil; 205 | if (self.navigationItem.hlj_barButtonItemFont) { 206 | font = self.navigationItem.hlj_barButtonItemFont; 207 | }else if (self.navigationController.navigationBar.hlj_barButtonItemFont) { 208 | font = self.navigationController.navigationBar.hlj_barButtonItemFont; 209 | if (!self.navigationController && self.hlj_private_barButtonItemFont) { 210 | font = self.hlj_private_barButtonItemFont; 211 | } 212 | }else { 213 | font = [[UINavigationBar appearance] hlj_barButtonItemFont]; 214 | if (!self.navigationController && self.hlj_private_barButtonItemFont) { 215 | font = self.hlj_private_barButtonItemFont; 216 | } 217 | } 218 | 219 | self.hlj_private_barButtonItemFont = font; 220 | return font; 221 | } 222 | 223 | - (UIColor *)hlj_navBarTitleColor { 224 | UIColor *color = nil; 225 | if (self.navigationItem.hlj_navBarTitleColor) { 226 | color = self.navigationItem.hlj_navBarTitleColor; 227 | }else if (self.navigationController.navigationBar.hlj_titleColor) { 228 | color = self.navigationController.navigationBar.hlj_titleColor; 229 | if (!self.navigationController && self.hlj_private_navBarTitleColor) { 230 | color = self.hlj_private_navBarTitleColor; 231 | } 232 | }else { 233 | color = [[UINavigationBar appearance] hlj_titleColor]; 234 | if (!self.navigationController && self.hlj_private_navBarTitleColor) { 235 | color = self.hlj_private_navBarTitleColor; 236 | } 237 | } 238 | 239 | self.hlj_private_navBarTitleColor = color; 240 | return color; 241 | } 242 | 243 | - (UIFont *)hlj_navBarTitleFont { 244 | UIFont *font = nil; 245 | if (self.navigationItem.hlj_navBarTitleFont) { 246 | font = self.navigationItem.hlj_navBarTitleFont; 247 | }else if (self.navigationController.navigationBar.hlj_font) { 248 | font = self.navigationController.navigationBar.hlj_font; 249 | if (!self.navigationController && self.hlj_private_navBarTitleFont) { 250 | font = self.hlj_private_navBarTitleFont; 251 | } 252 | }else { 253 | font = [[UINavigationBar appearance] hlj_font]; 254 | if (!self.navigationController && self.hlj_private_navBarTitleFont) { 255 | font = self.hlj_private_navBarTitleFont; 256 | } 257 | } 258 | 259 | self.hlj_private_navBarTitleFont = font; 260 | return font; 261 | } 262 | 263 | - (UIColor *)hlj_private_navBarShadowColor { 264 | return objc_getAssociatedObject(self, @selector(hlj_private_navBarShadowColor)); 265 | } 266 | 267 | - (void)setHlj_private_navBarShadowColor:(UIColor *)hlj_private_navBarShadowColor { 268 | objc_setAssociatedObject(self, @selector(hlj_private_navBarShadowColor), hlj_private_navBarShadowColor, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 269 | } 270 | 271 | - (UIColor *)hlj_private_navBarBackgroundColor { 272 | return objc_getAssociatedObject(self, @selector(hlj_private_navBarBackgroundColor)); 273 | } 274 | 275 | - (void)setHlj_private_navBarBackgroundColor:(UIColor *)hlj_private_navBarBackgroundColor { 276 | objc_setAssociatedObject(self, @selector(hlj_private_navBarBackgroundColor), hlj_private_navBarBackgroundColor, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 277 | } 278 | 279 | - (CGFloat)hlj_private_navBarBgAlpha { 280 | if ( objc_getAssociatedObject(self, @selector(hlj_private_navBarBgAlpha))) { 281 | return [objc_getAssociatedObject(self, @selector(hlj_private_navBarBgAlpha)) floatValue]; 282 | } 283 | return -1; 284 | } 285 | 286 | - (void)setHlj_private_navBarBgAlpha:(CGFloat)hlj_private_navBarBgAlpha { 287 | objc_setAssociatedObject(self, @selector(hlj_private_navBarBgAlpha), @(hlj_private_navBarBgAlpha), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 288 | } 289 | 290 | - (UIColor *)hlj_private_barButtonItemTintColor { 291 | return objc_getAssociatedObject(self, @selector(hlj_private_barButtonItemTintColor)); 292 | } 293 | 294 | - (void)setHlj_private_barButtonItemTintColor:(UIColor *)hlj_private_barButtonItemTintColor { 295 | objc_setAssociatedObject(self, @selector(hlj_private_barButtonItemTintColor), hlj_private_barButtonItemTintColor, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 296 | } 297 | 298 | - (UIFont *)hlj_private_barButtonItemFont { 299 | return objc_getAssociatedObject(self, @selector(hlj_private_barButtonItemFont)); 300 | } 301 | 302 | - (void)setHlj_private_barButtonItemFont:(UIFont *)hlj_private_barButtonItemFont { 303 | objc_setAssociatedObject(self, @selector(hlj_private_barButtonItemFont), hlj_private_barButtonItemFont, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 304 | } 305 | 306 | - (UIColor *)hlj_private_navBarTitleColor { 307 | return objc_getAssociatedObject(self, @selector(hlj_private_navBarTitleColor)); 308 | } 309 | 310 | - (void)setHlj_private_navBarTitleColor:(UIColor *)hlj_private_navBarTitleColor { 311 | objc_setAssociatedObject(self, @selector(hlj_private_navBarTitleColor), hlj_private_navBarTitleColor, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 312 | } 313 | 314 | - (UIFont *)hlj_private_navBarTitleFont { 315 | return objc_getAssociatedObject(self, @selector(hlj_private_navBarTitleFont)); 316 | } 317 | 318 | - (void)setHlj_private_navBarTitleFont:(UIFont *)hlj_private_navBarTitleFont { 319 | objc_setAssociatedObject(self, @selector(hlj_private_navBarTitleFont), hlj_private_navBarTitleFont, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 320 | } 321 | 322 | 323 | @end 324 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 BulletWu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HLJNavigationBar 2 | 3 | iOS11 完美适配 4 | 5 | 1.提供2种方法处理导航栏隐藏显示 6 | 7 | /* 8 | hlj_prefersNavigationBarHidden ,直接hidden导航栏 9 | hlj_navBarBgAlpha,修改透明度 10 | */ 11 | 12 | 2.导航栏颜色可变 13 | 14 | 3.导航栏颜色,透明度变化,过渡 15 | 16 | 4.自定义返回按钮,不使用leftBarButtonItem 17 | 18 | 5.支持 滑动,点击返回事件的回调 19 | 20 | /* 21 | - (BOOL)navigationShouldPop; //是否允许触发返 22 | - (void)navigationDidPop;//pop成功 ,因为侧滑返回可能取消 23 | - (void)navigationPopCancel;//侧滑返回取消 24 | */ 25 | 26 | 27 | 7.支持动态更新切换NavigationItem 28 | -------------------------------------------------------------------------------- /_Pods.xcodeproj: -------------------------------------------------------------------------------- 1 | Example/Pods/Pods.xcodeproj --------------------------------------------------------------------------------