├── .gitignore ├── .slather.yml ├── .travis.yml ├── Example ├── NavKitExample.xcworkspace │ └── contents.xcworkspacedata └── NavKitExample │ ├── NavKitExample.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── NavKitExample │ ├── AppDelegate.swift │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── DetailViewController.swift │ ├── Info.plist │ ├── MainViewController.swift │ └── MoreTableViewController.swift ├── LICENSE ├── NavKit.podspec ├── NavKit.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ └── NavKit.xcscheme ├── NavKit ├── CustomizableNavigation.swift ├── Info.plist └── NavKit.h ├── NavKitTests ├── Info.plist ├── NavKitTests.swift └── ViewController.swift ├── README.md └── Resources ├── Blink Navigation Bar.gif ├── Navigation Bar with Color.png └── Transition Navigation Bar.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | ## Playgrounds 31 | timeline.xctimeline 32 | playground.xcworkspace 33 | 34 | # Swift Package Manager 35 | # 36 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 37 | # Packages/ 38 | .build/ 39 | 40 | # CocoaPods 41 | # 42 | # We recommend against adding the Pods directory to your .gitignore. However 43 | # you should judge for yourself, the pros and cons are mentioned at: 44 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 45 | # 46 | # Pods/ 47 | 48 | # Carthage 49 | # 50 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 51 | # Carthage/Checkouts 52 | 53 | Carthage/Build 54 | 55 | # fastlane 56 | # 57 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 58 | # screenshots whenever they are needed. 59 | # For more information about the recommended setup visit: 60 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 61 | 62 | fastlane/report.xml 63 | fastlane/Preview.html 64 | fastlane/screenshots 65 | fastlane/test_output 66 | -------------------------------------------------------------------------------- /.slather.yml: -------------------------------------------------------------------------------- 1 | coverage_service: coveralls 2 | xcodeproj: NavKit.xcodeproj 3 | scheme: NavKit 4 | source_directory: NavKit 5 | ignore: 6 | - NavKitTests/* 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | osx_image: xcode8 3 | env: 4 | global: 5 | - LC_CTYPE=en_US.UTF-8 6 | - LANG=en_US.UTF-8 7 | - PROJECT=NavKit.xcodeproj 8 | - SCHEME=NavKit 9 | - SDK=iphonesimulator10.0 10 | - DESTINATION="OS=10.0,name=iPhone 7 Plus" 11 | before_install: 12 | - gem install xcpretty -N 13 | - gem install slather --no-ri --no-rdoc 14 | script: 15 | - set -o pipefail 16 | - xcodebuild -version 17 | - xcodebuild -showsdks 18 | - xcodebuild -project "$PROJECT" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Debug ONLY_ACTIVE_ARCH=YES ENABLE_TESTABILITY=YES test | xcpretty -c; 19 | after_success: 20 | - slather 21 | -------------------------------------------------------------------------------- /Example/NavKitExample.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Example/NavKitExample/NavKitExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | CFAA09961EB6FFE3007BCB3F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CFAA09951EB6FFE3007BCB3F /* AppDelegate.swift */; }; 11 | CFAA099B1EB6FFE3007BCB3F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CFAA09991EB6FFE3007BCB3F /* Main.storyboard */; }; 12 | CFAA099D1EB6FFE3007BCB3F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CFAA099C1EB6FFE3007BCB3F /* Assets.xcassets */; }; 13 | CFAA09A01EB6FFE3007BCB3F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CFAA099E1EB6FFE3007BCB3F /* LaunchScreen.storyboard */; }; 14 | CFAA09B21EB700CF007BCB3F /* NavKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CFAA09B11EB700CF007BCB3F /* NavKit.framework */; }; 15 | CFAA09B41EB70142007BCB3F /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CFAA09B31EB70142007BCB3F /* MainViewController.swift */; }; 16 | CFAA09B61EB705CB007BCB3F /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CFAA09B51EB705CB007BCB3F /* DetailViewController.swift */; }; 17 | CFAA09B81EB708FA007BCB3F /* MoreTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CFAA09B71EB708FA007BCB3F /* MoreTableViewController.swift */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXFileReference section */ 21 | CFAA09921EB6FFE3007BCB3F /* NavKitExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NavKitExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 22 | CFAA09951EB6FFE3007BCB3F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 23 | CFAA099A1EB6FFE3007BCB3F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 24 | CFAA099C1EB6FFE3007BCB3F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 25 | CFAA099F1EB6FFE3007BCB3F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 26 | CFAA09A11EB6FFE3007BCB3F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 27 | CFAA09B11EB700CF007BCB3F /* NavKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NavKit.framework; path = "../../build/Debug-iphoneos/NavKit.framework"; sourceTree = ""; }; 28 | CFAA09B31EB70142007BCB3F /* MainViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = ""; }; 29 | CFAA09B51EB705CB007BCB3F /* DetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DetailViewController.swift; sourceTree = ""; }; 30 | CFAA09B71EB708FA007BCB3F /* MoreTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoreTableViewController.swift; sourceTree = ""; }; 31 | /* End PBXFileReference section */ 32 | 33 | /* Begin PBXFrameworksBuildPhase section */ 34 | CFAA098F1EB6FFE3007BCB3F /* Frameworks */ = { 35 | isa = PBXFrameworksBuildPhase; 36 | buildActionMask = 2147483647; 37 | files = ( 38 | CFAA09B21EB700CF007BCB3F /* NavKit.framework in Frameworks */, 39 | ); 40 | runOnlyForDeploymentPostprocessing = 0; 41 | }; 42 | /* End PBXFrameworksBuildPhase section */ 43 | 44 | /* Begin PBXGroup section */ 45 | CFAA09891EB6FFE2007BCB3F = { 46 | isa = PBXGroup; 47 | children = ( 48 | CFAA09941EB6FFE3007BCB3F /* NavKitExample */, 49 | CFAA09931EB6FFE3007BCB3F /* Products */, 50 | CFAA09B01EB700CF007BCB3F /* Frameworks */, 51 | ); 52 | sourceTree = ""; 53 | }; 54 | CFAA09931EB6FFE3007BCB3F /* Products */ = { 55 | isa = PBXGroup; 56 | children = ( 57 | CFAA09921EB6FFE3007BCB3F /* NavKitExample.app */, 58 | ); 59 | name = Products; 60 | sourceTree = ""; 61 | }; 62 | CFAA09941EB6FFE3007BCB3F /* NavKitExample */ = { 63 | isa = PBXGroup; 64 | children = ( 65 | CFAA09A11EB6FFE3007BCB3F /* Info.plist */, 66 | CFAA09951EB6FFE3007BCB3F /* AppDelegate.swift */, 67 | CFAA09B51EB705CB007BCB3F /* DetailViewController.swift */, 68 | CFAA09B31EB70142007BCB3F /* MainViewController.swift */, 69 | CFAA09B71EB708FA007BCB3F /* MoreTableViewController.swift */, 70 | CFAA099C1EB6FFE3007BCB3F /* Assets.xcassets */, 71 | CFAA099E1EB6FFE3007BCB3F /* LaunchScreen.storyboard */, 72 | CFAA09991EB6FFE3007BCB3F /* Main.storyboard */, 73 | ); 74 | path = NavKitExample; 75 | sourceTree = ""; 76 | }; 77 | CFAA09B01EB700CF007BCB3F /* Frameworks */ = { 78 | isa = PBXGroup; 79 | children = ( 80 | CFAA09B11EB700CF007BCB3F /* NavKit.framework */, 81 | ); 82 | name = Frameworks; 83 | sourceTree = ""; 84 | }; 85 | /* End PBXGroup section */ 86 | 87 | /* Begin PBXNativeTarget section */ 88 | CFAA09911EB6FFE3007BCB3F /* NavKitExample */ = { 89 | isa = PBXNativeTarget; 90 | buildConfigurationList = CFAA09A41EB6FFE3007BCB3F /* Build configuration list for PBXNativeTarget "NavKitExample" */; 91 | buildPhases = ( 92 | CFAA098E1EB6FFE3007BCB3F /* Sources */, 93 | CFAA098F1EB6FFE3007BCB3F /* Frameworks */, 94 | CFAA09901EB6FFE3007BCB3F /* Resources */, 95 | ); 96 | buildRules = ( 97 | ); 98 | dependencies = ( 99 | ); 100 | name = NavKitExample; 101 | productName = NavKitExample; 102 | productReference = CFAA09921EB6FFE3007BCB3F /* NavKitExample.app */; 103 | productType = "com.apple.product-type.application"; 104 | }; 105 | /* End PBXNativeTarget section */ 106 | 107 | /* Begin PBXProject section */ 108 | CFAA098A1EB6FFE2007BCB3F /* Project object */ = { 109 | isa = PBXProject; 110 | attributes = { 111 | LastSwiftUpdateCheck = 0830; 112 | LastUpgradeCheck = 0830; 113 | ORGANIZATIONNAME = "Wilbert Liu"; 114 | TargetAttributes = { 115 | CFAA09911EB6FFE3007BCB3F = { 116 | CreatedOnToolsVersion = 8.3.2; 117 | ProvisioningStyle = Automatic; 118 | }; 119 | }; 120 | }; 121 | buildConfigurationList = CFAA098D1EB6FFE2007BCB3F /* Build configuration list for PBXProject "NavKitExample" */; 122 | compatibilityVersion = "Xcode 3.2"; 123 | developmentRegion = English; 124 | hasScannedForEncodings = 0; 125 | knownRegions = ( 126 | en, 127 | Base, 128 | ); 129 | mainGroup = CFAA09891EB6FFE2007BCB3F; 130 | productRefGroup = CFAA09931EB6FFE3007BCB3F /* Products */; 131 | projectDirPath = ""; 132 | projectRoot = ""; 133 | targets = ( 134 | CFAA09911EB6FFE3007BCB3F /* NavKitExample */, 135 | ); 136 | }; 137 | /* End PBXProject section */ 138 | 139 | /* Begin PBXResourcesBuildPhase section */ 140 | CFAA09901EB6FFE3007BCB3F /* Resources */ = { 141 | isa = PBXResourcesBuildPhase; 142 | buildActionMask = 2147483647; 143 | files = ( 144 | CFAA09A01EB6FFE3007BCB3F /* LaunchScreen.storyboard in Resources */, 145 | CFAA099D1EB6FFE3007BCB3F /* Assets.xcassets in Resources */, 146 | CFAA099B1EB6FFE3007BCB3F /* Main.storyboard in Resources */, 147 | ); 148 | runOnlyForDeploymentPostprocessing = 0; 149 | }; 150 | /* End PBXResourcesBuildPhase section */ 151 | 152 | /* Begin PBXSourcesBuildPhase section */ 153 | CFAA098E1EB6FFE3007BCB3F /* Sources */ = { 154 | isa = PBXSourcesBuildPhase; 155 | buildActionMask = 2147483647; 156 | files = ( 157 | CFAA09B61EB705CB007BCB3F /* DetailViewController.swift in Sources */, 158 | CFAA09961EB6FFE3007BCB3F /* AppDelegate.swift in Sources */, 159 | CFAA09B81EB708FA007BCB3F /* MoreTableViewController.swift in Sources */, 160 | CFAA09B41EB70142007BCB3F /* MainViewController.swift in Sources */, 161 | ); 162 | runOnlyForDeploymentPostprocessing = 0; 163 | }; 164 | /* End PBXSourcesBuildPhase section */ 165 | 166 | /* Begin PBXVariantGroup section */ 167 | CFAA09991EB6FFE3007BCB3F /* Main.storyboard */ = { 168 | isa = PBXVariantGroup; 169 | children = ( 170 | CFAA099A1EB6FFE3007BCB3F /* Base */, 171 | ); 172 | name = Main.storyboard; 173 | sourceTree = ""; 174 | }; 175 | CFAA099E1EB6FFE3007BCB3F /* LaunchScreen.storyboard */ = { 176 | isa = PBXVariantGroup; 177 | children = ( 178 | CFAA099F1EB6FFE3007BCB3F /* Base */, 179 | ); 180 | name = LaunchScreen.storyboard; 181 | sourceTree = ""; 182 | }; 183 | /* End PBXVariantGroup section */ 184 | 185 | /* Begin XCBuildConfiguration section */ 186 | CFAA09A21EB6FFE3007BCB3F /* Debug */ = { 187 | isa = XCBuildConfiguration; 188 | buildSettings = { 189 | ALWAYS_SEARCH_USER_PATHS = NO; 190 | CLANG_ANALYZER_NONNULL = YES; 191 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 192 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 193 | CLANG_CXX_LIBRARY = "libc++"; 194 | CLANG_ENABLE_MODULES = YES; 195 | CLANG_ENABLE_OBJC_ARC = YES; 196 | CLANG_WARN_BOOL_CONVERSION = YES; 197 | CLANG_WARN_CONSTANT_CONVERSION = YES; 198 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 199 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 200 | CLANG_WARN_EMPTY_BODY = YES; 201 | CLANG_WARN_ENUM_CONVERSION = YES; 202 | CLANG_WARN_INFINITE_RECURSION = YES; 203 | CLANG_WARN_INT_CONVERSION = YES; 204 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 205 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 206 | CLANG_WARN_UNREACHABLE_CODE = YES; 207 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 208 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 209 | COPY_PHASE_STRIP = NO; 210 | DEBUG_INFORMATION_FORMAT = dwarf; 211 | ENABLE_STRICT_OBJC_MSGSEND = YES; 212 | ENABLE_TESTABILITY = YES; 213 | GCC_C_LANGUAGE_STANDARD = gnu99; 214 | GCC_DYNAMIC_NO_PIC = NO; 215 | GCC_NO_COMMON_BLOCKS = YES; 216 | GCC_OPTIMIZATION_LEVEL = 0; 217 | GCC_PREPROCESSOR_DEFINITIONS = ( 218 | "DEBUG=1", 219 | "$(inherited)", 220 | ); 221 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 222 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 223 | GCC_WARN_UNDECLARED_SELECTOR = YES; 224 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 225 | GCC_WARN_UNUSED_FUNCTION = YES; 226 | GCC_WARN_UNUSED_VARIABLE = YES; 227 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 228 | MTL_ENABLE_DEBUG_INFO = YES; 229 | ONLY_ACTIVE_ARCH = YES; 230 | SDKROOT = iphoneos; 231 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 232 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 233 | }; 234 | name = Debug; 235 | }; 236 | CFAA09A31EB6FFE3007BCB3F /* Release */ = { 237 | isa = XCBuildConfiguration; 238 | buildSettings = { 239 | ALWAYS_SEARCH_USER_PATHS = NO; 240 | CLANG_ANALYZER_NONNULL = YES; 241 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 242 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 243 | CLANG_CXX_LIBRARY = "libc++"; 244 | CLANG_ENABLE_MODULES = YES; 245 | CLANG_ENABLE_OBJC_ARC = YES; 246 | CLANG_WARN_BOOL_CONVERSION = YES; 247 | CLANG_WARN_CONSTANT_CONVERSION = YES; 248 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 249 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 250 | CLANG_WARN_EMPTY_BODY = YES; 251 | CLANG_WARN_ENUM_CONVERSION = YES; 252 | CLANG_WARN_INFINITE_RECURSION = YES; 253 | CLANG_WARN_INT_CONVERSION = YES; 254 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 255 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 256 | CLANG_WARN_UNREACHABLE_CODE = YES; 257 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 258 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 259 | COPY_PHASE_STRIP = NO; 260 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 261 | ENABLE_NS_ASSERTIONS = NO; 262 | ENABLE_STRICT_OBJC_MSGSEND = YES; 263 | GCC_C_LANGUAGE_STANDARD = gnu99; 264 | GCC_NO_COMMON_BLOCKS = YES; 265 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 266 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 267 | GCC_WARN_UNDECLARED_SELECTOR = YES; 268 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 269 | GCC_WARN_UNUSED_FUNCTION = YES; 270 | GCC_WARN_UNUSED_VARIABLE = YES; 271 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 272 | MTL_ENABLE_DEBUG_INFO = NO; 273 | SDKROOT = iphoneos; 274 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 275 | VALIDATE_PRODUCT = YES; 276 | }; 277 | name = Release; 278 | }; 279 | CFAA09A51EB6FFE3007BCB3F /* Debug */ = { 280 | isa = XCBuildConfiguration; 281 | buildSettings = { 282 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 283 | INFOPLIST_FILE = NavKitExample/Info.plist; 284 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 285 | PRODUCT_BUNDLE_IDENTIFIER = com.wilbertliu.NavKitExample; 286 | PRODUCT_NAME = "$(TARGET_NAME)"; 287 | SWIFT_VERSION = 3.0; 288 | }; 289 | name = Debug; 290 | }; 291 | CFAA09A61EB6FFE3007BCB3F /* Release */ = { 292 | isa = XCBuildConfiguration; 293 | buildSettings = { 294 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 295 | INFOPLIST_FILE = NavKitExample/Info.plist; 296 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 297 | PRODUCT_BUNDLE_IDENTIFIER = com.wilbertliu.NavKitExample; 298 | PRODUCT_NAME = "$(TARGET_NAME)"; 299 | SWIFT_VERSION = 3.0; 300 | }; 301 | name = Release; 302 | }; 303 | /* End XCBuildConfiguration section */ 304 | 305 | /* Begin XCConfigurationList section */ 306 | CFAA098D1EB6FFE2007BCB3F /* Build configuration list for PBXProject "NavKitExample" */ = { 307 | isa = XCConfigurationList; 308 | buildConfigurations = ( 309 | CFAA09A21EB6FFE3007BCB3F /* Debug */, 310 | CFAA09A31EB6FFE3007BCB3F /* Release */, 311 | ); 312 | defaultConfigurationIsVisible = 0; 313 | defaultConfigurationName = Release; 314 | }; 315 | CFAA09A41EB6FFE3007BCB3F /* Build configuration list for PBXNativeTarget "NavKitExample" */ = { 316 | isa = XCConfigurationList; 317 | buildConfigurations = ( 318 | CFAA09A51EB6FFE3007BCB3F /* Debug */, 319 | CFAA09A61EB6FFE3007BCB3F /* Release */, 320 | ); 321 | defaultConfigurationIsVisible = 0; 322 | }; 323 | /* End XCConfigurationList section */ 324 | }; 325 | rootObject = CFAA098A1EB6FFE2007BCB3F /* Project object */; 326 | } 327 | -------------------------------------------------------------------------------- /Example/NavKitExample/NavKitExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/NavKitExample/NavKitExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // NavKitExample 4 | // 5 | // Created by Wilbert Liu on 5/1/17. 6 | // Copyright © 2017 Wilbert Liu. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /Example/NavKitExample/NavKitExample/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | } 43 | ], 44 | "info" : { 45 | "version" : 1, 46 | "author" : "xcode" 47 | } 48 | } -------------------------------------------------------------------------------- /Example/NavKitExample/NavKitExample/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 | -------------------------------------------------------------------------------- /Example/NavKitExample/NavKitExample/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 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /Example/NavKitExample/NavKitExample/DetailViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DetailViewController.swift 3 | // NavKitExample 4 | // 5 | // Created by Wilbert Liu on 5/1/17. 6 | // Copyright © 2017 Wilbert Liu. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import NavKit 11 | 12 | class DetailViewController: UIViewController, CustomizableNavigation, UIGestureRecognizerDelegate { 13 | // MARK: - Navigation Config 14 | 15 | var barBackgroundColor: UIColor = UIColor.blue.withAlphaComponent(0.5) 16 | var backText: String? = "<-- Go back" 17 | 18 | // MARK: - Life Cycles 19 | 20 | override func viewWillAppear(_ animated: Bool) { 21 | super.viewWillAppear(animated) 22 | navigationController?.navigationBar.tintColor = .white 23 | self.updateNavigation() 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Example/NavKitExample/NavKitExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /Example/NavKitExample/NavKitExample/MainViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MainViewController.swift 3 | // NavKitExample 4 | // 5 | // Created by Wilbert Liu on 5/1/17. 6 | // Copyright © 2017 Wilbert Liu. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import NavKit 11 | 12 | class MainViewController: UIViewController, CustomizableNavigation, UIGestureRecognizerDelegate { 13 | // MARK: - Properties 14 | 15 | var barAlpha: CGFloat = 1 16 | var alphaDirection: Int = 0 17 | var timer: Timer! 18 | 19 | // MARK: - Navigation Config 20 | 21 | var barBackgroundColor: UIColor = .magenta 22 | 23 | // MARK: - Life Cycles 24 | 25 | override func viewWillAppear(_ animated: Bool) { 26 | super.viewWillAppear(animated) 27 | 28 | timer = Timer.scheduledTimer(timeInterval: 0.1, 29 | target: self, 30 | selector: #selector(timerEventOccured(_:)), 31 | userInfo: nil, 32 | repeats: true) 33 | 34 | self.updateNavigation() 35 | } 36 | 37 | override func viewWillDisappear(_ animated: Bool) { 38 | super.viewWillDisappear(animated) 39 | timer.invalidate() 40 | } 41 | 42 | // MARK: - Actions 43 | 44 | func timerEventOccured(_ sender: Any) { 45 | if alphaDirection == 0 { 46 | barAlpha -= 0.1 47 | } else { 48 | barAlpha += 0.1 49 | } 50 | 51 | if barAlpha <= 0 { 52 | alphaDirection = 1 53 | barAlpha = 0 54 | } else if barAlpha >= 1 { 55 | alphaDirection = 0 56 | barAlpha = 1 57 | } 58 | 59 | barBackgroundColor = barBackgroundColor.withAlphaComponent(barAlpha) 60 | self.updateNavigation() 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Example/NavKitExample/NavKitExample/MoreTableViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MoreTableViewController.swift 3 | // NavKitExample 4 | // 5 | // Created by Wilbert Liu on 5/1/17. 6 | // Copyright © 2017 Wilbert Liu. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import NavKit 11 | 12 | class MoreTableViewController: UITableViewController, CustomizableNavigation, UIGestureRecognizerDelegate { 13 | // MARK: - Navigation Config 14 | 15 | var barBackgroundColor: UIColor = UIColor.cyan.withAlphaComponent(0) 16 | var backText: String? = "<-- Go back" 17 | 18 | // MARK: - Life Cycles 19 | 20 | override func viewWillAppear(_ animated: Bool) { 21 | super.viewWillAppear(animated) 22 | self.updateNavigation() 23 | } 24 | 25 | // MARK: - Table View Data Source 26 | 27 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 28 | return 50 29 | } 30 | 31 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 32 | let cell = tableView.dequeueReusableCell(withIdentifier: "moreCell", for: indexPath) 33 | 34 | cell.textLabel?.text = "\(indexPath.row + 1)" 35 | 36 | return cell 37 | } 38 | 39 | // MARK: - Scroll View Delegate 40 | 41 | override func scrollViewDidScroll(_ scrollView: UIScrollView) { 42 | var barAlpha = scrollView.contentOffset.y * 0.002 43 | barAlpha = min(barAlpha, 1) 44 | barBackgroundColor = barBackgroundColor.withAlphaComponent(barAlpha) 45 | self.updateNavigation() 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Wilbert Liu 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 | -------------------------------------------------------------------------------- /NavKit.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'NavKit' 3 | s.version = '0.5' 4 | s.license = 'MIT' 5 | s.summary = 'Simple and integrated way to customize navigation bar experience on iOS app.' 6 | s.homepage = 'https://github.com/wilbertliu/NavKit' 7 | s.social_media_url = 'https://twitter.com/wilbertliu' 8 | s.authors = { 'Wilbert Liu' => 'wilbertliu@gmail.com' } 9 | s.source = { :git => 'https://github.com/wilbertliu/NavKit.git', :tag => '0.5' } 10 | s.ios.deployment_target = '8.0' 11 | s.source_files = 'NavKit', 'NavKit/**/*.{h,m,swift}' 12 | end 13 | -------------------------------------------------------------------------------- /NavKit.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | CF2468C81E811C14003B570B /* NavKit.h in Headers */ = {isa = PBXBuildFile; fileRef = CF2468C61E811C14003B570B /* NavKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; 11 | CF2468DF1E811E5E003B570B /* NavKitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF2468D91E811C3D003B570B /* NavKitTests.swift */; }; 12 | CF2468E31E811E68003B570B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF2468CC1E811C2E003B570B /* ViewController.swift */; }; 13 | CFCB9B451E8121620021A294 /* CustomizableNavigation.swift in Sources */ = {isa = PBXBuildFile; fileRef = CFCB9B441E8121620021A294 /* CustomizableNavigation.swift */; }; 14 | CFE5913A1E7D3EE6004C536B /* NavKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CFE591301E7D3EE6004C536B /* NavKit.framework */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXContainerItemProxy section */ 18 | CFE5913B1E7D3EE6004C536B /* PBXContainerItemProxy */ = { 19 | isa = PBXContainerItemProxy; 20 | containerPortal = CFE591271E7D3EE6004C536B /* Project object */; 21 | proxyType = 1; 22 | remoteGlobalIDString = CFE5912F1E7D3EE6004C536B; 23 | remoteInfo = NavigationKit; 24 | }; 25 | /* End PBXContainerItemProxy section */ 26 | 27 | /* Begin PBXFileReference section */ 28 | CF2468C51E811C14003B570B /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = NavKit/Info.plist; sourceTree = SOURCE_ROOT; }; 29 | CF2468C61E811C14003B570B /* NavKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NavKit.h; path = NavKit/NavKit.h; sourceTree = SOURCE_ROOT; }; 30 | CF2468CC1E811C2E003B570B /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ViewController.swift; path = NavKitTests/ViewController.swift; sourceTree = SOURCE_ROOT; }; 31 | CF2468D91E811C3D003B570B /* NavKitTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NavKitTests.swift; path = NavKitTests/NavKitTests.swift; sourceTree = SOURCE_ROOT; }; 32 | CF2468DB1E811C46003B570B /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = NavKitTests/Info.plist; sourceTree = SOURCE_ROOT; }; 33 | CFCB9B441E8121620021A294 /* CustomizableNavigation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CustomizableNavigation.swift; path = NavKit/CustomizableNavigation.swift; sourceTree = SOURCE_ROOT; }; 34 | CFE591301E7D3EE6004C536B /* NavKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = NavKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 35 | CFE591391E7D3EE6004C536B /* NavKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NavKitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 36 | /* End PBXFileReference section */ 37 | 38 | /* Begin PBXFrameworksBuildPhase section */ 39 | CFE5912C1E7D3EE6004C536B /* Frameworks */ = { 40 | isa = PBXFrameworksBuildPhase; 41 | buildActionMask = 2147483647; 42 | files = ( 43 | ); 44 | runOnlyForDeploymentPostprocessing = 0; 45 | }; 46 | CFE591361E7D3EE6004C536B /* Frameworks */ = { 47 | isa = PBXFrameworksBuildPhase; 48 | buildActionMask = 2147483647; 49 | files = ( 50 | CFE5913A1E7D3EE6004C536B /* NavKit.framework in Frameworks */, 51 | ); 52 | runOnlyForDeploymentPostprocessing = 0; 53 | }; 54 | /* End PBXFrameworksBuildPhase section */ 55 | 56 | /* Begin PBXGroup section */ 57 | CF3702041E7D9B3400D38715 /* Tests */ = { 58 | isa = PBXGroup; 59 | children = ( 60 | CF2468D91E811C3D003B570B /* NavKitTests.swift */, 61 | ); 62 | name = Tests; 63 | sourceTree = ""; 64 | }; 65 | CF3702051E7D9B4300D38715 /* Fakers */ = { 66 | isa = PBXGroup; 67 | children = ( 68 | CF2468CC1E811C2E003B570B /* ViewController.swift */, 69 | ); 70 | name = Fakers; 71 | sourceTree = ""; 72 | }; 73 | CFBE26A81E7D404800464B61 /* Support */ = { 74 | isa = PBXGroup; 75 | children = ( 76 | CF2468C51E811C14003B570B /* Info.plist */, 77 | CF2468C61E811C14003B570B /* NavKit.h */, 78 | ); 79 | name = Support; 80 | sourceTree = ""; 81 | }; 82 | CFBE26A91E7D405500464B61 /* Sources */ = { 83 | isa = PBXGroup; 84 | children = ( 85 | CFCB9B441E8121620021A294 /* CustomizableNavigation.swift */, 86 | ); 87 | name = Sources; 88 | sourceTree = ""; 89 | }; 90 | CFE591261E7D3EE6004C536B = { 91 | isa = PBXGroup; 92 | children = ( 93 | CFE591321E7D3EE6004C536B /* NavKit */, 94 | CFE5913D1E7D3EE6004C536B /* NavKitTests */, 95 | CFE591311E7D3EE6004C536B /* Products */, 96 | ); 97 | sourceTree = ""; 98 | }; 99 | CFE591311E7D3EE6004C536B /* Products */ = { 100 | isa = PBXGroup; 101 | children = ( 102 | CFE591301E7D3EE6004C536B /* NavKit.framework */, 103 | CFE591391E7D3EE6004C536B /* NavKitTests.xctest */, 104 | ); 105 | name = Products; 106 | sourceTree = ""; 107 | }; 108 | CFE591321E7D3EE6004C536B /* NavKit */ = { 109 | isa = PBXGroup; 110 | children = ( 111 | CFBE26A91E7D405500464B61 /* Sources */, 112 | CFBE26A81E7D404800464B61 /* Support */, 113 | ); 114 | name = NavKit; 115 | path = NavigationKit; 116 | sourceTree = ""; 117 | }; 118 | CFE5913D1E7D3EE6004C536B /* NavKitTests */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | CF2468DB1E811C46003B570B /* Info.plist */, 122 | CF3702051E7D9B4300D38715 /* Fakers */, 123 | CF3702041E7D9B3400D38715 /* Tests */, 124 | ); 125 | name = NavKitTests; 126 | path = NavigationKitTests; 127 | sourceTree = ""; 128 | }; 129 | /* End PBXGroup section */ 130 | 131 | /* Begin PBXHeadersBuildPhase section */ 132 | CFE5912D1E7D3EE6004C536B /* Headers */ = { 133 | isa = PBXHeadersBuildPhase; 134 | buildActionMask = 2147483647; 135 | files = ( 136 | CF2468C81E811C14003B570B /* NavKit.h in Headers */, 137 | ); 138 | runOnlyForDeploymentPostprocessing = 0; 139 | }; 140 | /* End PBXHeadersBuildPhase section */ 141 | 142 | /* Begin PBXNativeTarget section */ 143 | CFE5912F1E7D3EE6004C536B /* NavKit */ = { 144 | isa = PBXNativeTarget; 145 | buildConfigurationList = CFE591441E7D3EE6004C536B /* Build configuration list for PBXNativeTarget "NavKit" */; 146 | buildPhases = ( 147 | CFE5912B1E7D3EE6004C536B /* Sources */, 148 | CFE5912C1E7D3EE6004C536B /* Frameworks */, 149 | CFE5912D1E7D3EE6004C536B /* Headers */, 150 | CFE5912E1E7D3EE6004C536B /* Resources */, 151 | ); 152 | buildRules = ( 153 | ); 154 | dependencies = ( 155 | ); 156 | name = NavKit; 157 | productName = NavigationKit; 158 | productReference = CFE591301E7D3EE6004C536B /* NavKit.framework */; 159 | productType = "com.apple.product-type.framework"; 160 | }; 161 | CFE591381E7D3EE6004C536B /* NavKitTests */ = { 162 | isa = PBXNativeTarget; 163 | buildConfigurationList = CFE591471E7D3EE6004C536B /* Build configuration list for PBXNativeTarget "NavKitTests" */; 164 | buildPhases = ( 165 | CFE591351E7D3EE6004C536B /* Sources */, 166 | CFE591361E7D3EE6004C536B /* Frameworks */, 167 | CFE591371E7D3EE6004C536B /* Resources */, 168 | ); 169 | buildRules = ( 170 | ); 171 | dependencies = ( 172 | CFE5913C1E7D3EE6004C536B /* PBXTargetDependency */, 173 | ); 174 | name = NavKitTests; 175 | productName = NavigationKitTests; 176 | productReference = CFE591391E7D3EE6004C536B /* NavKitTests.xctest */; 177 | productType = "com.apple.product-type.bundle.unit-test"; 178 | }; 179 | /* End PBXNativeTarget section */ 180 | 181 | /* Begin PBXProject section */ 182 | CFE591271E7D3EE6004C536B /* Project object */ = { 183 | isa = PBXProject; 184 | attributes = { 185 | LastSwiftUpdateCheck = 0820; 186 | LastUpgradeCheck = 0830; 187 | ORGANIZATIONNAME = "Wilbert Liu"; 188 | TargetAttributes = { 189 | CFE5912F1E7D3EE6004C536B = { 190 | CreatedOnToolsVersion = 8.2.1; 191 | LastSwiftMigration = 0820; 192 | ProvisioningStyle = Automatic; 193 | }; 194 | CFE591381E7D3EE6004C536B = { 195 | CreatedOnToolsVersion = 8.2.1; 196 | DevelopmentTeam = 9PCAZJDB4X; 197 | ProvisioningStyle = Automatic; 198 | }; 199 | }; 200 | }; 201 | buildConfigurationList = CFE5912A1E7D3EE6004C536B /* Build configuration list for PBXProject "NavKit" */; 202 | compatibilityVersion = "Xcode 3.2"; 203 | developmentRegion = English; 204 | hasScannedForEncodings = 0; 205 | knownRegions = ( 206 | en, 207 | ); 208 | mainGroup = CFE591261E7D3EE6004C536B; 209 | productRefGroup = CFE591311E7D3EE6004C536B /* Products */; 210 | projectDirPath = ""; 211 | projectRoot = ""; 212 | targets = ( 213 | CFE5912F1E7D3EE6004C536B /* NavKit */, 214 | CFE591381E7D3EE6004C536B /* NavKitTests */, 215 | ); 216 | }; 217 | /* End PBXProject section */ 218 | 219 | /* Begin PBXResourcesBuildPhase section */ 220 | CFE5912E1E7D3EE6004C536B /* Resources */ = { 221 | isa = PBXResourcesBuildPhase; 222 | buildActionMask = 2147483647; 223 | files = ( 224 | ); 225 | runOnlyForDeploymentPostprocessing = 0; 226 | }; 227 | CFE591371E7D3EE6004C536B /* Resources */ = { 228 | isa = PBXResourcesBuildPhase; 229 | buildActionMask = 2147483647; 230 | files = ( 231 | ); 232 | runOnlyForDeploymentPostprocessing = 0; 233 | }; 234 | /* End PBXResourcesBuildPhase section */ 235 | 236 | /* Begin PBXSourcesBuildPhase section */ 237 | CFE5912B1E7D3EE6004C536B /* Sources */ = { 238 | isa = PBXSourcesBuildPhase; 239 | buildActionMask = 2147483647; 240 | files = ( 241 | CFCB9B451E8121620021A294 /* CustomizableNavigation.swift in Sources */, 242 | ); 243 | runOnlyForDeploymentPostprocessing = 0; 244 | }; 245 | CFE591351E7D3EE6004C536B /* Sources */ = { 246 | isa = PBXSourcesBuildPhase; 247 | buildActionMask = 2147483647; 248 | files = ( 249 | CF2468E31E811E68003B570B /* ViewController.swift in Sources */, 250 | CF2468DF1E811E5E003B570B /* NavKitTests.swift in Sources */, 251 | ); 252 | runOnlyForDeploymentPostprocessing = 0; 253 | }; 254 | /* End PBXSourcesBuildPhase section */ 255 | 256 | /* Begin PBXTargetDependency section */ 257 | CFE5913C1E7D3EE6004C536B /* PBXTargetDependency */ = { 258 | isa = PBXTargetDependency; 259 | target = CFE5912F1E7D3EE6004C536B /* NavKit */; 260 | targetProxy = CFE5913B1E7D3EE6004C536B /* PBXContainerItemProxy */; 261 | }; 262 | /* End PBXTargetDependency section */ 263 | 264 | /* Begin XCBuildConfiguration section */ 265 | CFE591421E7D3EE6004C536B /* Debug */ = { 266 | isa = XCBuildConfiguration; 267 | buildSettings = { 268 | ALWAYS_SEARCH_USER_PATHS = NO; 269 | CLANG_ANALYZER_NONNULL = YES; 270 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 271 | CLANG_CXX_LIBRARY = "libc++"; 272 | CLANG_ENABLE_MODULES = YES; 273 | CLANG_ENABLE_OBJC_ARC = YES; 274 | CLANG_WARN_BOOL_CONVERSION = YES; 275 | CLANG_WARN_CONSTANT_CONVERSION = YES; 276 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 277 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 278 | CLANG_WARN_EMPTY_BODY = YES; 279 | CLANG_WARN_ENUM_CONVERSION = YES; 280 | CLANG_WARN_INFINITE_RECURSION = YES; 281 | CLANG_WARN_INT_CONVERSION = YES; 282 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 283 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 284 | CLANG_WARN_UNREACHABLE_CODE = YES; 285 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 286 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 287 | COPY_PHASE_STRIP = NO; 288 | CURRENT_PROJECT_VERSION = 1; 289 | DEBUG_INFORMATION_FORMAT = dwarf; 290 | ENABLE_STRICT_OBJC_MSGSEND = YES; 291 | ENABLE_TESTABILITY = YES; 292 | GCC_C_LANGUAGE_STANDARD = gnu99; 293 | GCC_DYNAMIC_NO_PIC = NO; 294 | GCC_NO_COMMON_BLOCKS = YES; 295 | GCC_OPTIMIZATION_LEVEL = 0; 296 | GCC_PREPROCESSOR_DEFINITIONS = ( 297 | "DEBUG=1", 298 | "$(inherited)", 299 | ); 300 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 301 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 302 | GCC_WARN_UNDECLARED_SELECTOR = YES; 303 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 304 | GCC_WARN_UNUSED_FUNCTION = YES; 305 | GCC_WARN_UNUSED_VARIABLE = YES; 306 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 307 | MTL_ENABLE_DEBUG_INFO = YES; 308 | ONLY_ACTIVE_ARCH = YES; 309 | SDKROOT = iphoneos; 310 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 311 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 312 | TARGETED_DEVICE_FAMILY = "1,2"; 313 | VERSIONING_SYSTEM = "apple-generic"; 314 | VERSION_INFO_PREFIX = ""; 315 | }; 316 | name = Debug; 317 | }; 318 | CFE591431E7D3EE6004C536B /* Release */ = { 319 | isa = XCBuildConfiguration; 320 | buildSettings = { 321 | ALWAYS_SEARCH_USER_PATHS = NO; 322 | CLANG_ANALYZER_NONNULL = YES; 323 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 324 | CLANG_CXX_LIBRARY = "libc++"; 325 | CLANG_ENABLE_MODULES = YES; 326 | CLANG_ENABLE_OBJC_ARC = YES; 327 | CLANG_WARN_BOOL_CONVERSION = YES; 328 | CLANG_WARN_CONSTANT_CONVERSION = YES; 329 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 330 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 331 | CLANG_WARN_EMPTY_BODY = YES; 332 | CLANG_WARN_ENUM_CONVERSION = YES; 333 | CLANG_WARN_INFINITE_RECURSION = YES; 334 | CLANG_WARN_INT_CONVERSION = YES; 335 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 336 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 337 | CLANG_WARN_UNREACHABLE_CODE = YES; 338 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 339 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 340 | COPY_PHASE_STRIP = NO; 341 | CURRENT_PROJECT_VERSION = 1; 342 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 343 | ENABLE_NS_ASSERTIONS = NO; 344 | ENABLE_STRICT_OBJC_MSGSEND = YES; 345 | GCC_C_LANGUAGE_STANDARD = gnu99; 346 | GCC_NO_COMMON_BLOCKS = YES; 347 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 348 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 349 | GCC_WARN_UNDECLARED_SELECTOR = YES; 350 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 351 | GCC_WARN_UNUSED_FUNCTION = YES; 352 | GCC_WARN_UNUSED_VARIABLE = YES; 353 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 354 | MTL_ENABLE_DEBUG_INFO = NO; 355 | SDKROOT = iphoneos; 356 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 357 | TARGETED_DEVICE_FAMILY = "1,2"; 358 | VALIDATE_PRODUCT = YES; 359 | VERSIONING_SYSTEM = "apple-generic"; 360 | VERSION_INFO_PREFIX = ""; 361 | }; 362 | name = Release; 363 | }; 364 | CFE591451E7D3EE6004C536B /* Debug */ = { 365 | isa = XCBuildConfiguration; 366 | buildSettings = { 367 | CLANG_ENABLE_MODULES = YES; 368 | CODE_SIGN_IDENTITY = ""; 369 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 370 | DEFINES_MODULE = YES; 371 | DEVELOPMENT_TEAM = ""; 372 | DYLIB_COMPATIBILITY_VERSION = 1; 373 | DYLIB_CURRENT_VERSION = 1; 374 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 375 | INFOPLIST_FILE = "$(SRCROOT)/NavKit/Info.plist"; 376 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 377 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 378 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 379 | PRODUCT_BUNDLE_IDENTIFIER = com.wilbertliu.NavKit; 380 | PRODUCT_NAME = "$(TARGET_NAME)"; 381 | SKIP_INSTALL = YES; 382 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 383 | SWIFT_VERSION = 3.0; 384 | }; 385 | name = Debug; 386 | }; 387 | CFE591461E7D3EE6004C536B /* Release */ = { 388 | isa = XCBuildConfiguration; 389 | buildSettings = { 390 | CLANG_ENABLE_MODULES = YES; 391 | CODE_SIGN_IDENTITY = ""; 392 | DEFINES_MODULE = YES; 393 | DEVELOPMENT_TEAM = ""; 394 | DYLIB_COMPATIBILITY_VERSION = 1; 395 | DYLIB_CURRENT_VERSION = 1; 396 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 397 | INFOPLIST_FILE = "$(SRCROOT)/NavKit/Info.plist"; 398 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 399 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 400 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 401 | PRODUCT_BUNDLE_IDENTIFIER = com.wilbertliu.NavKit; 402 | PRODUCT_NAME = "$(TARGET_NAME)"; 403 | SKIP_INSTALL = YES; 404 | SWIFT_VERSION = 3.0; 405 | }; 406 | name = Release; 407 | }; 408 | CFE591481E7D3EE6004C536B /* Debug */ = { 409 | isa = XCBuildConfiguration; 410 | buildSettings = { 411 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 412 | DEVELOPMENT_TEAM = 9PCAZJDB4X; 413 | INFOPLIST_FILE = NavKitTests/Info.plist; 414 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 415 | PRODUCT_BUNDLE_IDENTIFIER = com.wilbertliu.NavKitTests; 416 | PRODUCT_NAME = "$(TARGET_NAME)"; 417 | SWIFT_VERSION = 3.0; 418 | }; 419 | name = Debug; 420 | }; 421 | CFE591491E7D3EE6004C536B /* Release */ = { 422 | isa = XCBuildConfiguration; 423 | buildSettings = { 424 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 425 | DEVELOPMENT_TEAM = 9PCAZJDB4X; 426 | INFOPLIST_FILE = NavKitTests/Info.plist; 427 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 428 | PRODUCT_BUNDLE_IDENTIFIER = com.wilbertliu.NavKitTests; 429 | PRODUCT_NAME = "$(TARGET_NAME)"; 430 | SWIFT_VERSION = 3.0; 431 | }; 432 | name = Release; 433 | }; 434 | /* End XCBuildConfiguration section */ 435 | 436 | /* Begin XCConfigurationList section */ 437 | CFE5912A1E7D3EE6004C536B /* Build configuration list for PBXProject "NavKit" */ = { 438 | isa = XCConfigurationList; 439 | buildConfigurations = ( 440 | CFE591421E7D3EE6004C536B /* Debug */, 441 | CFE591431E7D3EE6004C536B /* Release */, 442 | ); 443 | defaultConfigurationIsVisible = 0; 444 | defaultConfigurationName = Release; 445 | }; 446 | CFE591441E7D3EE6004C536B /* Build configuration list for PBXNativeTarget "NavKit" */ = { 447 | isa = XCConfigurationList; 448 | buildConfigurations = ( 449 | CFE591451E7D3EE6004C536B /* Debug */, 450 | CFE591461E7D3EE6004C536B /* Release */, 451 | ); 452 | defaultConfigurationIsVisible = 0; 453 | defaultConfigurationName = Release; 454 | }; 455 | CFE591471E7D3EE6004C536B /* Build configuration list for PBXNativeTarget "NavKitTests" */ = { 456 | isa = XCConfigurationList; 457 | buildConfigurations = ( 458 | CFE591481E7D3EE6004C536B /* Debug */, 459 | CFE591491E7D3EE6004C536B /* Release */, 460 | ); 461 | defaultConfigurationIsVisible = 0; 462 | defaultConfigurationName = Release; 463 | }; 464 | /* End XCConfigurationList section */ 465 | }; 466 | rootObject = CFE591271E7D3EE6004C536B /* Project object */; 467 | } 468 | -------------------------------------------------------------------------------- /NavKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /NavKit.xcodeproj/xcshareddata/xcschemes/NavKit.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 | 65 | 66 | 72 | 73 | 74 | 75 | 76 | 77 | 83 | 84 | 90 | 91 | 92 | 93 | 95 | 96 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /NavKit/CustomizableNavigation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CustomizableNavigation.swift 3 | // NavKit 4 | // 5 | // Created by Wilbert Liu on 3/18/17. 6 | // Copyright © 2017 Wilbert Liu. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// It holds all required things for a type to specify the requirement of 12 | /// how the navigation bar with all of it's items look like and behave. 13 | public protocol CustomizableNavigation { 14 | /// Specify this property to determine the navigation bar background color. 15 | var barBackgroundColor: UIColor { get } 16 | 17 | /// Specify this property to determine whether or not the navigation bar 18 | /// would use shadow. Set the value to false to remove a *strange* 19 | /// line at the bottom of navigation bar. 20 | var isBarUsingBottomShadow: Bool { get } 21 | 22 | /// Specify this property to determine which title color that would be used 23 | /// at the midst of navigation bar. 24 | var titleColor: UIColor { get } 25 | 26 | /// Specify this property to determine which title font that would be used 27 | /// at the midst of navigation bar. 28 | var titleFont: UIFont { get } 29 | 30 | /// Specify this property to determine the image that would be used as 31 | /// the back button's image. 32 | var backImage: UIImage? { get } 33 | 34 | /// Specify this property to determine the text that would be used at 35 | /// the right of the back button's image. 36 | var backText: String? { get } 37 | 38 | /// Specify this property to determine whether or not the screen could be 39 | /// dragged from left to right to go to the previous screen. 40 | var isUsingInteractivePopGesture: Bool { get } 41 | 42 | /// Update the navigation configuration based on the specified properties. 43 | func updateNavigation() 44 | 45 | /// Reset the navigation configuration. 46 | func resetNavigation() 47 | } 48 | 49 | public extension CustomizableNavigation where Self: UIViewController, Self: UIGestureRecognizerDelegate { 50 | var barBackgroundColor: UIColor { return .white } 51 | var isBarUsingBottomShadow: Bool { return true } 52 | var titleColor: UIColor { return .black } 53 | var titleFont: UIFont { return .systemFont(ofSize: 17) } 54 | var backImage: UIImage? { return nil } 55 | var backText: String? { return nil } 56 | var isUsingInteractivePopGesture: Bool { return true } 57 | 58 | func updateNavigation() { 59 | let navigationBar = navigationController?.navigationBar 60 | 61 | navigationBar?.setBackgroundImage(UIImage(), for: .default) 62 | navigationBar?.shadowImage = isBarUsingBottomShadow ? nil : UIImage() 63 | 64 | var barView = navigationBar?.subviews.first?.subviews.first 65 | 66 | if barView == nil || barView != nil && type(of: barView!) != UIView.self { 67 | barView = UIView(frame: CGRect.zero) 68 | 69 | if let navBarSize = navigationBar?.frame.size { 70 | let statusBarSize = UIApplication.shared.statusBarFrame.size 71 | barView?.frame.size = CGSize(width: navBarSize.width, height: navBarSize.height + statusBarSize.height) 72 | } 73 | 74 | navigationBar?.subviews.first?.insertSubview(barView!, at: 0) 75 | } 76 | 77 | barView?.backgroundColor = barBackgroundColor 78 | 79 | var titleTextAttributes = navigationBar?.titleTextAttributes ?? [:] 80 | 81 | titleTextAttributes[NSForegroundColorAttributeName] = titleColor 82 | titleTextAttributes[NSFontAttributeName] = titleFont 83 | 84 | navigationBar?.titleTextAttributes = titleTextAttributes 85 | 86 | navigationItem.leftBarButtonItems = [] 87 | 88 | if let backImage = backImage { 89 | let imageButtonFrame = CGRect(x: 0, y: 0, width: backImage.size.width, height: backImage.size.height) 90 | let imageButton = UIButton(frame: imageButtonFrame) 91 | imageButton.setImage(backImage, for: .normal) 92 | imageButton.addTarget(self, action: #selector(backTapped(_:)), for: .touchUpInside) 93 | 94 | let imageBarButtonItem = UIBarButtonItem(customView: imageButton) 95 | navigationItem.leftBarButtonItems?.append(imageBarButtonItem) 96 | } 97 | 98 | if let backText = backText { 99 | let textBarButtonItem = UIBarButtonItem(title: backText, 100 | style: .plain, 101 | target: self, 102 | action: #selector(backTapped(_:))) 103 | navigationItem.leftBarButtonItems?.append(textBarButtonItem) 104 | } 105 | 106 | let interactivePopRecognizer = navigationController?.interactivePopGestureRecognizer 107 | interactivePopRecognizer?.isEnabled = isUsingInteractivePopGesture 108 | interactivePopRecognizer?.delegate = self 109 | } 110 | 111 | func resetNavigation() { 112 | let navigationBar = navigationController?.navigationBar 113 | 114 | navigationBar?.subviews.first?.subviews.first?.removeFromSuperview() 115 | navigationBar?.setBackgroundImage(nil, for: .default) 116 | navigationBar?.shadowImage = nil 117 | navigationBar?.titleTextAttributes = nil 118 | } 119 | } 120 | 121 | public extension UIViewController { 122 | /// Action that will be executed when the navigation bar has back button and it's tapped. 123 | /// 124 | /// - Parameter sender: The sender of action. 125 | func backTapped(_ sender: Any) { 126 | _ = navigationController?.popViewController(animated: true) 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /NavKit/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 0.5 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /NavKit/NavKit.h: -------------------------------------------------------------------------------- 1 | // 2 | // NavKit.h 3 | // NavKit 4 | // 5 | // Created by Wilbert Liu on 3/18/17. 6 | // Copyright © 2017 Wilbert Liu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for NavKit. 12 | FOUNDATION_EXPORT double NavKitVersionNumber; 13 | 14 | //! Project version string for NavKit. 15 | FOUNDATION_EXPORT const unsigned char NavKitVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /NavKitTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /NavKitTests/NavKitTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NavKitTests.swift 3 | // NavKitTests 4 | // 5 | // Created by Wilbert Liu on 3/18/17. 6 | // Copyright © 2017 Wilbert Liu. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import NavKit 11 | 12 | class NavKitTests: XCTestCase { 13 | // MARK: - Properties 14 | 15 | var controller: ViewController! 16 | var navController: UINavigationController! 17 | 18 | // MARK: - Life Cycles 19 | 20 | override func setUp() { 21 | super.setUp() 22 | 23 | controller = ViewController() 24 | navController = UINavigationController(rootViewController: controller) 25 | } 26 | 27 | override func tearDown() { 28 | super.tearDown() 29 | } 30 | 31 | // MARK: - Tests 32 | 33 | func testBarBackgroundColor() { 34 | controller.updateNavigation() 35 | XCTAssertNotNil(navController.navigationBar.backgroundImage(for: .default)) 36 | 37 | controller.barBackgroundColor = UIColor.white.withAlphaComponent(0.5) 38 | controller.updateNavigation() 39 | XCTAssertEqual(controller.barBackgroundColor, navController.navigationBar.subviews.first?.subviews.first?.backgroundColor) 40 | } 41 | 42 | func testBarShadow() { 43 | controller.updateNavigation() 44 | XCTAssertNil(navController.navigationBar.shadowImage) 45 | 46 | controller.isBarUsingBottomShadow = false 47 | controller.updateNavigation() 48 | XCTAssertNotNil(navController.navigationBar.shadowImage) 49 | } 50 | 51 | func testTitleColor() { 52 | controller.updateNavigation() 53 | 54 | let titleTextAttributes = navController.navigationBar.titleTextAttributes 55 | let titleColor = titleTextAttributes?[NSForegroundColorAttributeName] as! UIColor 56 | 57 | XCTAssertNotNil(titleTextAttributes) 58 | XCTAssertEqual(titleColor, .black) 59 | } 60 | 61 | func testTitleFont() { 62 | controller.updateNavigation() 63 | 64 | let titleTextAttributes = navController.navigationBar.titleTextAttributes 65 | let titleFont = titleTextAttributes?[NSFontAttributeName] as! UIFont 66 | 67 | XCTAssertNotNil(titleTextAttributes) 68 | XCTAssertEqual(titleFont, .systemFont(ofSize: 17)) 69 | } 70 | 71 | func testBackImage() { 72 | controller.backImage = UIImage() 73 | controller.updateNavigation() 74 | XCTAssertEqual(controller.navigationItem.leftBarButtonItems!.count, 1) 75 | 76 | let imageButton = controller.navigationItem.leftBarButtonItems!.first!.customView as! UIButton 77 | XCTAssertNotNil(imageButton.currentImage) 78 | } 79 | 80 | func testBackImageWithText() { 81 | controller.backImage = UIImage() 82 | controller.backText = "Back" 83 | controller.updateNavigation() 84 | 85 | XCTAssertEqual(controller.navigationItem.leftBarButtonItems!.count, 2) 86 | 87 | let imageButton = controller.navigationItem.leftBarButtonItems!.first!.customView as! UIButton 88 | XCTAssertNotNil(imageButton.currentImage) 89 | 90 | let title = controller.navigationItem.leftBarButtonItems!.last!.title 91 | XCTAssertEqual(title, controller.backText) 92 | } 93 | 94 | func testBackAction() { 95 | let lastController = ViewController() 96 | lastController.backImage = UIImage() 97 | lastController.backText = "Back" 98 | lastController.updateNavigation() 99 | 100 | navController.pushViewController(UIViewController(), animated: false) 101 | navController.pushViewController(lastController, animated: false) 102 | 103 | XCTAssertEqual(navController.viewControllers.count, 3) 104 | XCTAssertEqual(lastController.navigationItem.leftBarButtonItems!.count, 2) 105 | 106 | let imageButton = lastController.navigationItem.leftBarButtonItems!.first!.customView as! UIButton 107 | XCTAssertNotNil(imageButton.currentImage) 108 | 109 | imageButton.sendActions(for: .touchUpInside) 110 | XCTAssertNotEqual(navController.viewControllers.count, 2) 111 | } 112 | 113 | func testInteractivePopupGestureDelegate() { 114 | controller.updateNavigation() 115 | XCTAssertTrue(controller.isUsingInteractivePopGesture) 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /NavKitTests/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // NavKit 4 | // 5 | // Created by Wilbert Liu on 3/18/17. 6 | // Copyright © 2017 Wilbert Liu. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import NavKit 11 | 12 | class ViewController: UIViewController, CustomizableNavigation, UIGestureRecognizerDelegate { 13 | var barBackgroundColor: UIColor = .white 14 | var isBarUsingBottomShadow: Bool = true 15 | var titleColor: UIColor = .black 16 | var titleFont: UIFont = .systemFont(ofSize: 17) 17 | var backImage: UIImage? 18 | var backText: String? 19 | var isUsingInteractivePopGesture: Bool = true 20 | } 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NavKit 2 | 3 | [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 4 | [![Build Status](https://travis-ci.org/wilbertliu/NavKit.svg?branch=master)](https://travis-ci.org/wilbertliu/NavKit) 5 | [![Coverage Status](https://coveralls.io/repos/github/wilbertliu/NavKit/badge.svg?branch=master)](https://coveralls.io/github/wilbertliu/NavKit?branch=master) 6 | 7 | Simple and integrated way to customize navigation bar experience on iOS app. 8 | It should save our time that we usually use to make abstraction of navigation bar, 9 | back button, and so on. 10 | 11 | ## Demo 12 | 13 | ![Blink Navigation Bar](Resources/Blink%20Navigation%20Bar.gif) 14 | ![Navigation Bar with Color](Resources/Navigation%20Bar%20with%20Color.png) 15 | ![Transition Navigation Bar](Resources/Transition%20Navigation%20Bar.gif) 16 | 17 | ## Installation 18 | 19 | ### Carthage 20 | 21 | ``` 22 | github "wilbertliu/NavKit" 23 | ``` 24 | 25 | ### CocoaPods 26 | 27 | Add the following line into the `Podfile` : 28 | 29 | ``` 30 | pod 'NavKit' 31 | ``` 32 | 33 | After that, run the following command : 34 | 35 | ``` 36 | $ pod install 37 | ``` 38 | 39 | ## Usage 40 | 41 | Since the release of version `0.4`, NavKit has a huge redesign of its API. It makes the switch 42 | of the mindset to the view controller's based navigation configuration, which means 43 | we don't need additional layer to configure the navigation experience. 44 | 45 | There are only 3 things to do in order to use NavKit : 46 | 1. Conforms to protocol `CustomizableNavigation` **and** `UIGestureRecognizerDelegate`. 47 | 2. Define the properties that we need to customize the navigation bar like `barBackgroundColor`, `backImage`, etc. 48 | 3. Call `self.updateNavigation()` wherever in view controller to update the navigation bar based on the defined properties. 49 | 50 | ## Global Style 51 | 52 | There's a time when we want to make a general style because it would be used by most of the 53 | screens. What we have to do is just make a protocol extension of `CustomizableNavigation` 54 | and define the properties that we want to make as global. And of course, if you override 55 | the properties on some controller, NavKit would use what's defined at controller instead. 56 | Can we jump into some codes to show? 57 | 58 | ```swift 59 | import Foundation 60 | import NavKit 61 | 62 | extension CustomizableNavigation where Self: UIViewController, Self: UIGestureRecognizerDelegate { 63 | var titleColor: UIColor { return .red } 64 | var titleFont: UIFont { return UIFont.systemFont(ofSize: 16, weight: UIFontWeightMedium) } 65 | var backImage: UIImage? { return UIImage(named: "something") } 66 | } 67 | ``` 68 | 69 | ## Example 70 | 71 | Note that this section is taken from `Example` project. Make sure to check it to add some knowledge on how to use NavKit. 72 | 73 | ```swift 74 | import UIKit 75 | import NavKit 76 | 77 | class DetailViewController: UIViewController, CustomizableNavigation, UIGestureRecognizerDelegate { 78 | // MARK: - Navigation Config 79 | 80 | var barBackgroundColor: UIColor = UIColor.blue.withAlphaComponent(0.5) 81 | var backText: String? = "<-- Go back" 82 | 83 | // MARK: - Life Cycles 84 | 85 | override func viewWillAppear(_ animated: Bool) { 86 | super.viewWillAppear(animated) 87 | navigationController?.navigationBar.tintColor = .white 88 | self.updateNavigation() 89 | } 90 | } 91 | ``` 92 | 93 | ## Support 94 | 95 | Have any feedbacks? Feel free to submit a PR! And I'm more than happy to answer questions, or maybe just some hi?! To do that, shoot me a DM or tweet [@wilbertliu](https://twitter.com/wilbertliu) 96 | 97 | ## License 98 | 99 | MIT © Wilbert Liu 100 | -------------------------------------------------------------------------------- /Resources/Blink Navigation Bar.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilbertliu/NavKit/403533ce7c9216b8b0500a72bcff1e120d33552c/Resources/Blink Navigation Bar.gif -------------------------------------------------------------------------------- /Resources/Navigation Bar with Color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilbertliu/NavKit/403533ce7c9216b8b0500a72bcff1e120d33552c/Resources/Navigation Bar with Color.png -------------------------------------------------------------------------------- /Resources/Transition Navigation Bar.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilbertliu/NavKit/403533ce7c9216b8b0500a72bcff1e120d33552c/Resources/Transition Navigation Bar.gif --------------------------------------------------------------------------------