├── .gitignore ├── CHANGELOG.md ├── CRNavigationController.podspec ├── Classes ├── CRNavigationBar.h ├── CRNavigationBar.m ├── CRNavigationController.h └── CRNavigationController.m ├── Example ├── CRNavigationControllerExample.xcodeproj │ └── project.pbxproj ├── CRNavigationControllerExample │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── CRNavigationController │ │ ├── CRNavigationBar.h │ │ ├── CRNavigationBar.m │ │ ├── CRNavigationController.h │ │ └── CRNavigationController.m │ ├── CRNavigationControllerExample-Info.plist │ ├── CRNavigationControllerExample-Prefix.pch │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── LaunchImage.launchimage │ │ │ └── Contents.json │ ├── PrimaryViewController.h │ ├── PrimaryViewController.m │ ├── PrimaryViewController.xib │ ├── TestViewController.h │ ├── TestViewController.m │ ├── en.lproj │ │ └── InfoPlist.strings │ └── main.m └── Podfile ├── LICENSE ├── README.md └── Rakefile /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | *.xcworkspace 13 | !default.xcworkspace 14 | xcuserdata 15 | profile 16 | *.moved-aside 17 | DerivedData 18 | .idea/ 19 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # CRNavigationController CHANGELOG 2 | 3 | ## 0.1.0 4 | 5 | Initial release. 6 | -------------------------------------------------------------------------------- /CRNavigationController.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "CRNavigationController" 3 | s.version = "1.1" 4 | s.summary = "A UINavigationController subclass that brings about a more vivid, brighter UINavigationBar." 5 | s.description = <<-DESC 6 | CRNavigationController is a UINavigationController subclass that brings about a more vivid, brighter UINavigationBar. In light of iOS 7 bringing us the wonders of translucency, it's difficult to obtain bright and flush colors. This library solves that predicament. 7 | DESC 8 | s.homepage = "http://www.github.com/croberts22/CRNavigationController" 9 | s.license = 'MIT' 10 | s.author = { "Corey Roberts" => "croberts22@utexas.edu" } 11 | s.source = { :git => "https://github.com/croberts22/CRNavigationController.git", :tag => s.version.to_s } 12 | s.social_media_url = 'https://twitter.com/spacepyro/' 13 | s.platform = :ios, '6.0' 14 | s.ios.deployment_target = '6.0' 15 | s.requires_arc = true 16 | s.source_files = 'Classes/*.{h,m}' 17 | s.osx.exclude_files = 'Classes/ios' 18 | end 19 | -------------------------------------------------------------------------------- /Classes/CRNavigationBar.h: -------------------------------------------------------------------------------- 1 | // 2 | // CRNavigationBar.h 3 | // CRNavigationControllerExample 4 | // 5 | // Created by Corey Roberts on 9/24/13. 6 | // Copyright (c) 2013 SpacePyro Inc. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | #import 27 | 28 | /** 29 | * For use for devices running iOS 7.0.3 and later, up to iOS 7.1. This overrides the alpha value of any color 30 | * passed in to be 70%. Since (starting with this version) the blur effect is ultimately 31 | * determined by the transparency of the color, setting this to a value other than 1.0f will 32 | * provide said blurriness. Values between 0.5f and 0.7f seem to work best while still trying 33 | * to retain most of the desired color. 34 | * @warning: Setting this value to 1.0f will reduce blurred translucency significantly. 35 | */ 36 | static CGFloat const kDefaultNavigationBarAlpha = 0.70f; 37 | 38 | @interface CRNavigationBar : UINavigationBar 39 | 40 | /** 41 | * If set to YES, this will override the opacity of the barTintColor and will set it to 42 | * the value contained in kDefaultNavigationBarAlpha. 43 | */ 44 | @property (nonatomic, assign) BOOL overrideOpacity; 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /Classes/CRNavigationBar.m: -------------------------------------------------------------------------------- 1 | // 2 | // CRNavigationBar.m 3 | // CRNavigationControllerExample 4 | // 5 | // Created by Corey Roberts on 9/24/13. 6 | // Copyright (c) 2013 SpacePyro Inc. All rights reserved. 7 | // 8 | 9 | #import "CRNavigationBar.h" 10 | 11 | @interface CRNavigationBar () 12 | @property (nonatomic, strong) CALayer *colorLayer; 13 | @end 14 | 15 | @implementation CRNavigationBar 16 | 17 | #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) 18 | 19 | static CGFloat const kDefaultColorLayerOpacity = 0.5f; 20 | static CGFloat const kSpaceToCoverStatusBars = 20.0f; 21 | 22 | - (void)setBarTintColor:(UIColor *)barTintColor { 23 | 24 | [super setBarTintColor:barTintColor]; 25 | 26 | // iOS 7.1 seems to completely ignore the alpha channel and any modifications to it. 27 | // Hence, adding an extra layer is moot. 28 | // Still looking into possible solutions for this, but for now, this method is empty. 29 | if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.1")) { 30 | 31 | } 32 | // As of iOS 7.0.3, colors definitely seem a little bit more saturated. 33 | else if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0.3")) { 34 | 35 | // Override the opacity if wanted. 36 | if(self.overrideOpacity) { 37 | CGFloat red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0; 38 | [barTintColor getRed:&red green:&green blue:&blue alpha:&alpha]; 39 | [super setBarTintColor:[UIColor colorWithRed:red green:green blue:blue alpha:kDefaultNavigationBarAlpha]]; 40 | } 41 | 42 | // This code isn't perfect and has been commented out for now. It seems like 43 | // the additional color layer doesn't work well now that translucency is based 44 | // primarily on the opacity of the navigation bar (and its respective layers). 45 | // However, if you'd like to experiment, feel free to uncomment this out and 46 | // give it a spin. 47 | 48 | // if (self.colorLayer == nil) { 49 | // self.colorLayer = [CALayer layer]; 50 | // self.colorLayer.opacity = kDefaultColorLayerOpacity - 0.2f; 51 | // [self.layer addSublayer:self.colorLayer]; 52 | // } 53 | 54 | // self.colorLayer.backgroundColor = barTintColor.CGColor; 55 | } 56 | // iOS 7.0 benefits from the extra color layer. 57 | else { 58 | 59 | // Create a CALayer with some opacity, and add the layer. 60 | if (self.colorLayer == nil) { 61 | self.colorLayer = [CALayer layer]; 62 | self.colorLayer.opacity = kDefaultColorLayerOpacity; 63 | [self.layer addSublayer:self.colorLayer]; 64 | } 65 | 66 | self.colorLayer.backgroundColor = barTintColor.CGColor; 67 | } 68 | } 69 | 70 | - (void)layoutSubviews { 71 | [super layoutSubviews]; 72 | 73 | if (self.colorLayer != nil) { 74 | self.colorLayer.frame = CGRectMake(0, 0 - kSpaceToCoverStatusBars, CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds) + kSpaceToCoverStatusBars); 75 | 76 | [self.layer insertSublayer:self.colorLayer atIndex:1]; 77 | } 78 | } 79 | 80 | @end 81 | -------------------------------------------------------------------------------- /Classes/CRNavigationController.h: -------------------------------------------------------------------------------- 1 | // 2 | // CRNavigationController.h 3 | // CRNavigationControllerExample 4 | // 5 | // Created by Corey Roberts on 9/24/13. 6 | // Copyright (c) 2013 SpacePyro Inc. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | #import 27 | 28 | @interface CRNavigationController : UINavigationController 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Classes/CRNavigationController.m: -------------------------------------------------------------------------------- 1 | // 2 | // CRNavigationController.m 3 | // CRNavigationControllerExample 4 | // 5 | // Created by Corey Roberts on 9/24/13. 6 | // Copyright (c) 2013 SpacePyro Inc. All rights reserved. 7 | // 8 | 9 | #import "CRNavigationController.h" 10 | #import "CRNavigationBar.h" 11 | 12 | @interface CRNavigationController () 13 | 14 | @end 15 | 16 | @implementation CRNavigationController 17 | 18 | - (id)init { 19 | self = [super initWithNavigationBarClass:[CRNavigationBar class] toolbarClass:nil]; 20 | if(self) { 21 | // Custom initialization here, if needed. 22 | 23 | // To override the opacity of CRNavigationBar's barTintColor, set this value to YES. 24 | ((CRNavigationBar *)self.navigationBar).overrideOpacity = NO; 25 | } 26 | return self; 27 | } 28 | 29 | - (id)initWithRootViewController:(UIViewController *)rootViewController { 30 | self = [super initWithNavigationBarClass:[CRNavigationBar class] toolbarClass:nil]; 31 | if(self) { 32 | self.viewControllers = @[rootViewController]; 33 | 34 | // To override the opacity of CRNavigationBar's barTintColor, set this value to YES. 35 | ((CRNavigationBar *)self.navigationBar).overrideOpacity = NO; 36 | } 37 | 38 | return self; 39 | } 40 | 41 | - (UIStatusBarStyle)preferredStatusBarStyle { 42 | return UIStatusBarStyleLightContent; 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /Example/CRNavigationControllerExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 637D254617FB209700800F08 /* TestViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 637D254517FB209700800F08 /* TestViewController.m */; }; 11 | 63C925C817F2633D00DE97BB /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63C925C717F2633D00DE97BB /* Foundation.framework */; }; 12 | 63C925CA17F2633D00DE97BB /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63C925C917F2633D00DE97BB /* CoreGraphics.framework */; }; 13 | 63C925CC17F2633D00DE97BB /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63C925CB17F2633D00DE97BB /* UIKit.framework */; }; 14 | 63C925D217F2633D00DE97BB /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 63C925D017F2633D00DE97BB /* InfoPlist.strings */; }; 15 | 63C925D417F2633D00DE97BB /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 63C925D317F2633D00DE97BB /* main.m */; }; 16 | 63C925D817F2633D00DE97BB /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 63C925D717F2633D00DE97BB /* AppDelegate.m */; }; 17 | 63C925DA17F2633D00DE97BB /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 63C925D917F2633D00DE97BB /* Images.xcassets */; }; 18 | 63C925E117F2633D00DE97BB /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63C925E017F2633D00DE97BB /* XCTest.framework */; }; 19 | 63C925E217F2633D00DE97BB /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63C925C717F2633D00DE97BB /* Foundation.framework */; }; 20 | 63C925E317F2633D00DE97BB /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63C925CB17F2633D00DE97BB /* UIKit.framework */; }; 21 | 63C925F817F2636500DE97BB /* PrimaryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 63C925F717F2636500DE97BB /* PrimaryViewController.m */; }; 22 | 63C925FB17F2639700DE97BB /* CRNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 63C925FA17F2639700DE97BB /* CRNavigationController.m */; }; 23 | 63C9260217F263D000DE97BB /* CRNavigationBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 63C9260117F263D000DE97BB /* CRNavigationBar.m */; }; 24 | 63C9260517F2655200DE97BB /* PrimaryViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 63C9260417F2655200DE97BB /* PrimaryViewController.xib */; }; 25 | /* End PBXBuildFile section */ 26 | 27 | /* Begin PBXContainerItemProxy section */ 28 | 63C925E417F2633D00DE97BB /* PBXContainerItemProxy */ = { 29 | isa = PBXContainerItemProxy; 30 | containerPortal = 63C925BC17F2633D00DE97BB /* Project object */; 31 | proxyType = 1; 32 | remoteGlobalIDString = 63C925C317F2633D00DE97BB; 33 | remoteInfo = CRNavigationControllerExample; 34 | }; 35 | /* End PBXContainerItemProxy section */ 36 | 37 | /* Begin PBXFileReference section */ 38 | 637D254417FB209700800F08 /* TestViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestViewController.h; sourceTree = ""; }; 39 | 637D254517FB209700800F08 /* TestViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestViewController.m; sourceTree = ""; }; 40 | 63C925C417F2633D00DE97BB /* CRNavigationControllerExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CRNavigationControllerExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | 63C925C717F2633D00DE97BB /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 42 | 63C925C917F2633D00DE97BB /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 43 | 63C925CB17F2633D00DE97BB /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 44 | 63C925CF17F2633D00DE97BB /* CRNavigationControllerExample-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "CRNavigationControllerExample-Info.plist"; sourceTree = ""; }; 45 | 63C925D117F2633D00DE97BB /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 46 | 63C925D317F2633D00DE97BB /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 47 | 63C925D517F2633D00DE97BB /* CRNavigationControllerExample-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CRNavigationControllerExample-Prefix.pch"; sourceTree = ""; }; 48 | 63C925D617F2633D00DE97BB /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 49 | 63C925D717F2633D00DE97BB /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 50 | 63C925D917F2633D00DE97BB /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 51 | 63C925DF17F2633D00DE97BB /* CRNavigationControllerExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CRNavigationControllerExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 52 | 63C925E017F2633D00DE97BB /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 53 | 63C925F617F2636500DE97BB /* PrimaryViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrimaryViewController.h; sourceTree = ""; }; 54 | 63C925F717F2636500DE97BB /* PrimaryViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PrimaryViewController.m; sourceTree = ""; }; 55 | 63C925F917F2639700DE97BB /* CRNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CRNavigationController.h; path = CRNavigationController/CRNavigationController.h; sourceTree = ""; }; 56 | 63C925FA17F2639700DE97BB /* CRNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CRNavigationController.m; path = CRNavigationController/CRNavigationController.m; sourceTree = ""; }; 57 | 63C9260017F263D000DE97BB /* CRNavigationBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CRNavigationBar.h; path = CRNavigationController/CRNavigationBar.h; sourceTree = ""; }; 58 | 63C9260117F263D000DE97BB /* CRNavigationBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CRNavigationBar.m; path = CRNavigationController/CRNavigationBar.m; sourceTree = ""; }; 59 | 63C9260417F2655200DE97BB /* PrimaryViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PrimaryViewController.xib; sourceTree = ""; }; 60 | /* End PBXFileReference section */ 61 | 62 | /* Begin PBXFrameworksBuildPhase section */ 63 | 63C925C117F2633D00DE97BB /* Frameworks */ = { 64 | isa = PBXFrameworksBuildPhase; 65 | buildActionMask = 2147483647; 66 | files = ( 67 | 63C925CA17F2633D00DE97BB /* CoreGraphics.framework in Frameworks */, 68 | 63C925CC17F2633D00DE97BB /* UIKit.framework in Frameworks */, 69 | 63C925C817F2633D00DE97BB /* Foundation.framework in Frameworks */, 70 | ); 71 | runOnlyForDeploymentPostprocessing = 0; 72 | }; 73 | 63C925DC17F2633D00DE97BB /* Frameworks */ = { 74 | isa = PBXFrameworksBuildPhase; 75 | buildActionMask = 2147483647; 76 | files = ( 77 | 63C925E117F2633D00DE97BB /* XCTest.framework in Frameworks */, 78 | 63C925E317F2633D00DE97BB /* UIKit.framework in Frameworks */, 79 | 63C925E217F2633D00DE97BB /* Foundation.framework in Frameworks */, 80 | ); 81 | runOnlyForDeploymentPostprocessing = 0; 82 | }; 83 | /* End PBXFrameworksBuildPhase section */ 84 | 85 | /* Begin PBXGroup section */ 86 | 63C925BB17F2633D00DE97BB = { 87 | isa = PBXGroup; 88 | children = ( 89 | 63C925CD17F2633D00DE97BB /* CRNavigationControllerExample */, 90 | 63C925C617F2633D00DE97BB /* Frameworks */, 91 | 63C925C517F2633D00DE97BB /* Products */, 92 | ); 93 | sourceTree = ""; 94 | }; 95 | 63C925C517F2633D00DE97BB /* Products */ = { 96 | isa = PBXGroup; 97 | children = ( 98 | 63C925C417F2633D00DE97BB /* CRNavigationControllerExample.app */, 99 | 63C925DF17F2633D00DE97BB /* CRNavigationControllerExampleTests.xctest */, 100 | ); 101 | name = Products; 102 | sourceTree = ""; 103 | }; 104 | 63C925C617F2633D00DE97BB /* Frameworks */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | 63C925C717F2633D00DE97BB /* Foundation.framework */, 108 | 63C925C917F2633D00DE97BB /* CoreGraphics.framework */, 109 | 63C925CB17F2633D00DE97BB /* UIKit.framework */, 110 | 63C925E017F2633D00DE97BB /* XCTest.framework */, 111 | ); 112 | name = Frameworks; 113 | sourceTree = ""; 114 | }; 115 | 63C925CD17F2633D00DE97BB /* CRNavigationControllerExample */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | 63C925FF17F263C200DE97BB /* CRNavigationController */, 119 | 63C925D617F2633D00DE97BB /* AppDelegate.h */, 120 | 63C925D717F2633D00DE97BB /* AppDelegate.m */, 121 | 63C925D917F2633D00DE97BB /* Images.xcassets */, 122 | 63C925CE17F2633D00DE97BB /* Supporting Files */, 123 | 63C925F617F2636500DE97BB /* PrimaryViewController.h */, 124 | 63C925F717F2636500DE97BB /* PrimaryViewController.m */, 125 | 63C9260417F2655200DE97BB /* PrimaryViewController.xib */, 126 | 637D254417FB209700800F08 /* TestViewController.h */, 127 | 637D254517FB209700800F08 /* TestViewController.m */, 128 | ); 129 | path = CRNavigationControllerExample; 130 | sourceTree = ""; 131 | }; 132 | 63C925CE17F2633D00DE97BB /* Supporting Files */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | 63C925CF17F2633D00DE97BB /* CRNavigationControllerExample-Info.plist */, 136 | 63C925D017F2633D00DE97BB /* InfoPlist.strings */, 137 | 63C925D317F2633D00DE97BB /* main.m */, 138 | 63C925D517F2633D00DE97BB /* CRNavigationControllerExample-Prefix.pch */, 139 | ); 140 | name = "Supporting Files"; 141 | sourceTree = ""; 142 | }; 143 | 63C925FF17F263C200DE97BB /* CRNavigationController */ = { 144 | isa = PBXGroup; 145 | children = ( 146 | 63C9260017F263D000DE97BB /* CRNavigationBar.h */, 147 | 63C9260117F263D000DE97BB /* CRNavigationBar.m */, 148 | 63C925F917F2639700DE97BB /* CRNavigationController.h */, 149 | 63C925FA17F2639700DE97BB /* CRNavigationController.m */, 150 | ); 151 | name = CRNavigationController; 152 | sourceTree = ""; 153 | }; 154 | /* End PBXGroup section */ 155 | 156 | /* Begin PBXNativeTarget section */ 157 | 63C925C317F2633D00DE97BB /* CRNavigationControllerExample */ = { 158 | isa = PBXNativeTarget; 159 | buildConfigurationList = 63C925F017F2633D00DE97BB /* Build configuration list for PBXNativeTarget "CRNavigationControllerExample" */; 160 | buildPhases = ( 161 | 63C925C017F2633D00DE97BB /* Sources */, 162 | 63C925C117F2633D00DE97BB /* Frameworks */, 163 | 63C925C217F2633D00DE97BB /* Resources */, 164 | ); 165 | buildRules = ( 166 | ); 167 | dependencies = ( 168 | ); 169 | name = CRNavigationControllerExample; 170 | productName = CRNavigationControllerExample; 171 | productReference = 63C925C417F2633D00DE97BB /* CRNavigationControllerExample.app */; 172 | productType = "com.apple.product-type.application"; 173 | }; 174 | 63C925DE17F2633D00DE97BB /* CRNavigationControllerExampleTests */ = { 175 | isa = PBXNativeTarget; 176 | buildConfigurationList = 63C925F317F2633D00DE97BB /* Build configuration list for PBXNativeTarget "CRNavigationControllerExampleTests" */; 177 | buildPhases = ( 178 | 63C925DB17F2633D00DE97BB /* Sources */, 179 | 63C925DC17F2633D00DE97BB /* Frameworks */, 180 | 63C925DD17F2633D00DE97BB /* Resources */, 181 | ); 182 | buildRules = ( 183 | ); 184 | dependencies = ( 185 | 63C925E517F2633D00DE97BB /* PBXTargetDependency */, 186 | ); 187 | name = CRNavigationControllerExampleTests; 188 | productName = CRNavigationControllerExampleTests; 189 | productReference = 63C925DF17F2633D00DE97BB /* CRNavigationControllerExampleTests.xctest */; 190 | productType = "com.apple.product-type.bundle.unit-test"; 191 | }; 192 | /* End PBXNativeTarget section */ 193 | 194 | /* Begin PBXProject section */ 195 | 63C925BC17F2633D00DE97BB /* Project object */ = { 196 | isa = PBXProject; 197 | attributes = { 198 | LastUpgradeCheck = 0500; 199 | ORGANIZATIONNAME = "SpacePyro Inc."; 200 | TargetAttributes = { 201 | 63C925DE17F2633D00DE97BB = { 202 | TestTargetID = 63C925C317F2633D00DE97BB; 203 | }; 204 | }; 205 | }; 206 | buildConfigurationList = 63C925BF17F2633D00DE97BB /* Build configuration list for PBXProject "CRNavigationControllerExample" */; 207 | compatibilityVersion = "Xcode 3.2"; 208 | developmentRegion = English; 209 | hasScannedForEncodings = 0; 210 | knownRegions = ( 211 | en, 212 | ); 213 | mainGroup = 63C925BB17F2633D00DE97BB; 214 | productRefGroup = 63C925C517F2633D00DE97BB /* Products */; 215 | projectDirPath = ""; 216 | projectRoot = ""; 217 | targets = ( 218 | 63C925C317F2633D00DE97BB /* CRNavigationControllerExample */, 219 | 63C925DE17F2633D00DE97BB /* CRNavigationControllerExampleTests */, 220 | ); 221 | }; 222 | /* End PBXProject section */ 223 | 224 | /* Begin PBXResourcesBuildPhase section */ 225 | 63C925C217F2633D00DE97BB /* Resources */ = { 226 | isa = PBXResourcesBuildPhase; 227 | buildActionMask = 2147483647; 228 | files = ( 229 | 63C9260517F2655200DE97BB /* PrimaryViewController.xib in Resources */, 230 | 63C925D217F2633D00DE97BB /* InfoPlist.strings in Resources */, 231 | 63C925DA17F2633D00DE97BB /* Images.xcassets in Resources */, 232 | ); 233 | runOnlyForDeploymentPostprocessing = 0; 234 | }; 235 | 63C925DD17F2633D00DE97BB /* Resources */ = { 236 | isa = PBXResourcesBuildPhase; 237 | buildActionMask = 2147483647; 238 | files = ( 239 | ); 240 | runOnlyForDeploymentPostprocessing = 0; 241 | }; 242 | /* End PBXResourcesBuildPhase section */ 243 | 244 | /* Begin PBXSourcesBuildPhase section */ 245 | 63C925C017F2633D00DE97BB /* Sources */ = { 246 | isa = PBXSourcesBuildPhase; 247 | buildActionMask = 2147483647; 248 | files = ( 249 | 637D254617FB209700800F08 /* TestViewController.m in Sources */, 250 | 63C925FB17F2639700DE97BB /* CRNavigationController.m in Sources */, 251 | 63C925D817F2633D00DE97BB /* AppDelegate.m in Sources */, 252 | 63C925F817F2636500DE97BB /* PrimaryViewController.m in Sources */, 253 | 63C9260217F263D000DE97BB /* CRNavigationBar.m in Sources */, 254 | 63C925D417F2633D00DE97BB /* main.m in Sources */, 255 | ); 256 | runOnlyForDeploymentPostprocessing = 0; 257 | }; 258 | 63C925DB17F2633D00DE97BB /* Sources */ = { 259 | isa = PBXSourcesBuildPhase; 260 | buildActionMask = 2147483647; 261 | files = ( 262 | ); 263 | runOnlyForDeploymentPostprocessing = 0; 264 | }; 265 | /* End PBXSourcesBuildPhase section */ 266 | 267 | /* Begin PBXTargetDependency section */ 268 | 63C925E517F2633D00DE97BB /* PBXTargetDependency */ = { 269 | isa = PBXTargetDependency; 270 | target = 63C925C317F2633D00DE97BB /* CRNavigationControllerExample */; 271 | targetProxy = 63C925E417F2633D00DE97BB /* PBXContainerItemProxy */; 272 | }; 273 | /* End PBXTargetDependency section */ 274 | 275 | /* Begin PBXVariantGroup section */ 276 | 63C925D017F2633D00DE97BB /* InfoPlist.strings */ = { 277 | isa = PBXVariantGroup; 278 | children = ( 279 | 63C925D117F2633D00DE97BB /* en */, 280 | ); 281 | name = InfoPlist.strings; 282 | sourceTree = ""; 283 | }; 284 | /* End PBXVariantGroup section */ 285 | 286 | /* Begin XCBuildConfiguration section */ 287 | 63C925EE17F2633D00DE97BB /* Debug */ = { 288 | isa = XCBuildConfiguration; 289 | buildSettings = { 290 | ALWAYS_SEARCH_USER_PATHS = NO; 291 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 292 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 293 | CLANG_CXX_LIBRARY = "libc++"; 294 | CLANG_ENABLE_MODULES = YES; 295 | CLANG_ENABLE_OBJC_ARC = YES; 296 | CLANG_WARN_BOOL_CONVERSION = YES; 297 | CLANG_WARN_CONSTANT_CONVERSION = YES; 298 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 299 | CLANG_WARN_EMPTY_BODY = YES; 300 | CLANG_WARN_ENUM_CONVERSION = YES; 301 | CLANG_WARN_INT_CONVERSION = YES; 302 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 303 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 304 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 305 | COPY_PHASE_STRIP = NO; 306 | GCC_C_LANGUAGE_STANDARD = gnu99; 307 | GCC_DYNAMIC_NO_PIC = NO; 308 | GCC_OPTIMIZATION_LEVEL = 0; 309 | GCC_PREPROCESSOR_DEFINITIONS = ( 310 | "DEBUG=1", 311 | "$(inherited)", 312 | ); 313 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 314 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 315 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 316 | GCC_WARN_UNDECLARED_SELECTOR = YES; 317 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 318 | GCC_WARN_UNUSED_FUNCTION = YES; 319 | GCC_WARN_UNUSED_VARIABLE = YES; 320 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 321 | ONLY_ACTIVE_ARCH = YES; 322 | SDKROOT = iphoneos; 323 | }; 324 | name = Debug; 325 | }; 326 | 63C925EF17F2633D00DE97BB /* Release */ = { 327 | isa = XCBuildConfiguration; 328 | buildSettings = { 329 | ALWAYS_SEARCH_USER_PATHS = NO; 330 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 331 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 332 | CLANG_CXX_LIBRARY = "libc++"; 333 | CLANG_ENABLE_MODULES = YES; 334 | CLANG_ENABLE_OBJC_ARC = YES; 335 | CLANG_WARN_BOOL_CONVERSION = YES; 336 | CLANG_WARN_CONSTANT_CONVERSION = YES; 337 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 338 | CLANG_WARN_EMPTY_BODY = YES; 339 | CLANG_WARN_ENUM_CONVERSION = YES; 340 | CLANG_WARN_INT_CONVERSION = YES; 341 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 342 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 343 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 344 | COPY_PHASE_STRIP = YES; 345 | ENABLE_NS_ASSERTIONS = NO; 346 | GCC_C_LANGUAGE_STANDARD = gnu99; 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; 351 | GCC_WARN_UNUSED_FUNCTION = YES; 352 | GCC_WARN_UNUSED_VARIABLE = YES; 353 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 354 | SDKROOT = iphoneos; 355 | VALIDATE_PRODUCT = YES; 356 | }; 357 | name = Release; 358 | }; 359 | 63C925F117F2633D00DE97BB /* Debug */ = { 360 | isa = XCBuildConfiguration; 361 | buildSettings = { 362 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 363 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 364 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 365 | GCC_PREFIX_HEADER = "CRNavigationControllerExample/CRNavigationControllerExample-Prefix.pch"; 366 | INFOPLIST_FILE = "CRNavigationControllerExample/CRNavigationControllerExample-Info.plist"; 367 | PRODUCT_NAME = "$(TARGET_NAME)"; 368 | WRAPPER_EXTENSION = app; 369 | }; 370 | name = Debug; 371 | }; 372 | 63C925F217F2633D00DE97BB /* Release */ = { 373 | isa = XCBuildConfiguration; 374 | buildSettings = { 375 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 376 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 377 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 378 | GCC_PREFIX_HEADER = "CRNavigationControllerExample/CRNavigationControllerExample-Prefix.pch"; 379 | INFOPLIST_FILE = "CRNavigationControllerExample/CRNavigationControllerExample-Info.plist"; 380 | PRODUCT_NAME = "$(TARGET_NAME)"; 381 | WRAPPER_EXTENSION = app; 382 | }; 383 | name = Release; 384 | }; 385 | 63C925F417F2633D00DE97BB /* Debug */ = { 386 | isa = XCBuildConfiguration; 387 | buildSettings = { 388 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 389 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/CRNavigationControllerExample.app/CRNavigationControllerExample"; 390 | FRAMEWORK_SEARCH_PATHS = ( 391 | "$(SDKROOT)/Developer/Library/Frameworks", 392 | "$(inherited)", 393 | "$(DEVELOPER_FRAMEWORKS_DIR)", 394 | ); 395 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 396 | GCC_PREFIX_HEADER = "CRNavigationControllerExample/CRNavigationControllerExample-Prefix.pch"; 397 | GCC_PREPROCESSOR_DEFINITIONS = ( 398 | "DEBUG=1", 399 | "$(inherited)", 400 | ); 401 | INFOPLIST_FILE = "CRNavigationControllerExampleTests/CRNavigationControllerExampleTests-Info.plist"; 402 | PRODUCT_NAME = "$(TARGET_NAME)"; 403 | TEST_HOST = "$(BUNDLE_LOADER)"; 404 | WRAPPER_EXTENSION = xctest; 405 | }; 406 | name = Debug; 407 | }; 408 | 63C925F517F2633D00DE97BB /* Release */ = { 409 | isa = XCBuildConfiguration; 410 | buildSettings = { 411 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 412 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/CRNavigationControllerExample.app/CRNavigationControllerExample"; 413 | FRAMEWORK_SEARCH_PATHS = ( 414 | "$(SDKROOT)/Developer/Library/Frameworks", 415 | "$(inherited)", 416 | "$(DEVELOPER_FRAMEWORKS_DIR)", 417 | ); 418 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 419 | GCC_PREFIX_HEADER = "CRNavigationControllerExample/CRNavigationControllerExample-Prefix.pch"; 420 | INFOPLIST_FILE = "CRNavigationControllerExampleTests/CRNavigationControllerExampleTests-Info.plist"; 421 | PRODUCT_NAME = "$(TARGET_NAME)"; 422 | TEST_HOST = "$(BUNDLE_LOADER)"; 423 | WRAPPER_EXTENSION = xctest; 424 | }; 425 | name = Release; 426 | }; 427 | /* End XCBuildConfiguration section */ 428 | 429 | /* Begin XCConfigurationList section */ 430 | 63C925BF17F2633D00DE97BB /* Build configuration list for PBXProject "CRNavigationControllerExample" */ = { 431 | isa = XCConfigurationList; 432 | buildConfigurations = ( 433 | 63C925EE17F2633D00DE97BB /* Debug */, 434 | 63C925EF17F2633D00DE97BB /* Release */, 435 | ); 436 | defaultConfigurationIsVisible = 0; 437 | defaultConfigurationName = Release; 438 | }; 439 | 63C925F017F2633D00DE97BB /* Build configuration list for PBXNativeTarget "CRNavigationControllerExample" */ = { 440 | isa = XCConfigurationList; 441 | buildConfigurations = ( 442 | 63C925F117F2633D00DE97BB /* Debug */, 443 | 63C925F217F2633D00DE97BB /* Release */, 444 | ); 445 | defaultConfigurationIsVisible = 0; 446 | defaultConfigurationName = Release; 447 | }; 448 | 63C925F317F2633D00DE97BB /* Build configuration list for PBXNativeTarget "CRNavigationControllerExampleTests" */ = { 449 | isa = XCConfigurationList; 450 | buildConfigurations = ( 451 | 63C925F417F2633D00DE97BB /* Debug */, 452 | 63C925F517F2633D00DE97BB /* Release */, 453 | ); 454 | defaultConfigurationIsVisible = 0; 455 | defaultConfigurationName = Release; 456 | }; 457 | /* End XCConfigurationList section */ 458 | }; 459 | rootObject = 63C925BC17F2633D00DE97BB /* Project object */; 460 | } 461 | -------------------------------------------------------------------------------- /Example/CRNavigationControllerExample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // CRNavigationControllerExample 4 | // 5 | // Created by Corey Roberts on 9/24/13. 6 | // Copyright (c) 2013 SpacePyro Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Example/CRNavigationControllerExample/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // CRNavigationControllerExample 4 | // 5 | // Created by Corey Roberts on 9/24/13. 6 | // Copyright (c) 2013 SpacePyro Inc. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | #import "CRNavigationController.h" 12 | #import "PrimaryViewController.h" 13 | 14 | @implementation AppDelegate 15 | 16 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 17 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 18 | self.window.backgroundColor = [UIColor whiteColor]; 19 | [self.window makeKeyAndVisible]; 20 | 21 | PrimaryViewController *vc = [[PrimaryViewController alloc] initWithNibName:@"PrimaryViewController" bundle:nil]; 22 | CRNavigationController *nvc = [[CRNavigationController alloc] initWithRootViewController:vc]; 23 | 24 | self.window.rootViewController = nvc; 25 | 26 | UIColor *navigationTextColor = [UIColor whiteColor]; 27 | 28 | self.window.tintColor = navigationTextColor; 29 | 30 | [[UINavigationBar appearance] setTitleTextAttributes:@{ 31 | NSForegroundColorAttributeName : navigationTextColor 32 | }]; 33 | 34 | return YES; 35 | } 36 | 37 | - (void)applicationWillResignActive:(UIApplication *)application { 38 | // 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. 39 | // 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. 40 | } 41 | 42 | - (void)applicationDidEnterBackground:(UIApplication *)application { 43 | // 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. 44 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 45 | } 46 | 47 | - (void)applicationWillEnterForeground:(UIApplication *)application { 48 | // 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. 49 | } 50 | 51 | - (void)applicationDidBecomeActive:(UIApplication *)application { 52 | // 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. 53 | } 54 | 55 | - (void)applicationWillTerminate:(UIApplication *)application { 56 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 57 | } 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /Example/CRNavigationControllerExample/CRNavigationController/CRNavigationBar.h: -------------------------------------------------------------------------------- 1 | // 2 | // CRNavigationBar.h 3 | // CRNavigationControllerExample 4 | // 5 | // Created by Corey Roberts on 9/24/13. 6 | // Copyright (c) 2013 SpacePyro Inc. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | #import 27 | 28 | /** 29 | * For use for devices running iOS 7.0.3 and later, up to iOS 7.1. This overrides the alpha value of any color 30 | * passed in to be 70%. Since (starting with this version) the blur effect is ultimately 31 | * determined by the transparency of the color, setting this to a value other than 1.0f will 32 | * provide said blurriness. Values between 0.5f and 0.7f seem to work best while still trying 33 | * to retain most of the desired color. 34 | * @warning: Setting this value to 1.0f will reduce blurred translucency significantly. 35 | */ 36 | static CGFloat const kDefaultNavigationBarAlpha = 0.70f; 37 | 38 | @interface CRNavigationBar : UINavigationBar 39 | 40 | /** 41 | * If set to YES, this will override the opacity of the barTintColor and will set it to 42 | * the value contained in kDefaultNavigationBarAlpha. 43 | */ 44 | @property (nonatomic, assign) BOOL overrideOpacity; 45 | 46 | /** 47 | * Determines whether or not the extra color layer should be displayed. 48 | * @param display a BOOL; YES for keeping it visible, NO to hide it. 49 | * @warning this method is not available in the actual implementation, and is only here for demonstration purposes. 50 | */ 51 | - (void)displayColorLayer:(BOOL)display; 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /Example/CRNavigationControllerExample/CRNavigationController/CRNavigationBar.m: -------------------------------------------------------------------------------- 1 | // 2 | // CRNavigationBar.m 3 | // CRNavigationControllerExample 4 | // 5 | // Created by Corey Roberts on 9/24/13. 6 | // Copyright (c) 2013 SpacePyro Inc. All rights reserved. 7 | // 8 | 9 | #import "CRNavigationBar.h" 10 | 11 | @interface CRNavigationBar () 12 | @property (nonatomic, strong) CALayer *colorLayer; 13 | @end 14 | 15 | @implementation CRNavigationBar 16 | 17 | static CGFloat const kDefaultColorLayerOpacity = 0.5f; 18 | static CGFloat const kSpaceToCoverStatusBars = 20.0f; 19 | 20 | - (void)setBarTintColor:(UIColor *)barTintColor { 21 | 22 | [super setBarTintColor:barTintColor]; 23 | 24 | // iOS 7.1 seems to completely ignore the alpha channel and any modifications to it. 25 | // Hence, adding an extra layer is moot. 26 | // Still looking into possible solutions for this, but for now, this method is empty. 27 | if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.1")) { 28 | 29 | } 30 | // As of iOS 7.0.3, colors definitely seem a little bit more saturated. 31 | else if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0.3")) { 32 | 33 | // Override the opacity if wanted. 34 | if(self.overrideOpacity) { 35 | CGFloat red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0; 36 | [barTintColor getRed:&red green:&green blue:&blue alpha:&alpha]; 37 | [super setBarTintColor:[UIColor colorWithRed:red green:green blue:blue alpha:kDefaultNavigationBarAlpha]]; 38 | } 39 | 40 | // This code isn't perfect and has been commented out for now. It seems like 41 | // the additional color layer doesn't work well now that translucency is based 42 | // primarily on the opacity of the navigation bar (and its respective layers). 43 | // However, if you'd like to experiment, feel free to uncomment this out and 44 | // give it a spin. 45 | 46 | // if (self.colorLayer == nil) { 47 | // self.colorLayer = [CALayer layer]; 48 | // self.colorLayer.opacity = kDefaultColorLayerOpacity - 0.2f; 49 | // [self.layer addSublayer:self.colorLayer]; 50 | // } 51 | 52 | // self.colorLayer.backgroundColor = barTintColor.CGColor; 53 | } 54 | // iOS 7.0 benefits from the extra color layer. 55 | else { 56 | 57 | // Create a CALayer with some opacity, and add the layer. 58 | if (self.colorLayer == nil) { 59 | self.colorLayer = [CALayer layer]; 60 | self.colorLayer.opacity = kDefaultColorLayerOpacity; 61 | [self.layer addSublayer:self.colorLayer]; 62 | } 63 | 64 | self.colorLayer.backgroundColor = barTintColor.CGColor; 65 | } 66 | } 67 | 68 | - (void)layoutSubviews { 69 | [super layoutSubviews]; 70 | 71 | if (self.colorLayer != nil) { 72 | self.colorLayer.frame = CGRectMake(0, 0 - kSpaceToCoverStatusBars, CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds) + kSpaceToCoverStatusBars); 73 | 74 | [self.layer insertSublayer:self.colorLayer atIndex:1]; 75 | } 76 | } 77 | 78 | - (void)displayColorLayer:(BOOL)display { 79 | self.colorLayer.hidden = !display; 80 | } 81 | 82 | @end 83 | -------------------------------------------------------------------------------- /Example/CRNavigationControllerExample/CRNavigationController/CRNavigationController.h: -------------------------------------------------------------------------------- 1 | // 2 | // CRNavigationController.h 3 | // CRNavigationControllerExample 4 | // 5 | // Created by Corey Roberts on 9/24/13. 6 | // Copyright (c) 2013 SpacePyro Inc. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | #import 27 | 28 | @interface CRNavigationController : UINavigationController 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Example/CRNavigationControllerExample/CRNavigationController/CRNavigationController.m: -------------------------------------------------------------------------------- 1 | // 2 | // CRNavigationController.m 3 | // CRNavigationControllerExample 4 | // 5 | // Created by Corey Roberts on 9/24/13. 6 | // Copyright (c) 2013 SpacePyro Inc. All rights reserved. 7 | // 8 | 9 | #import "CRNavigationController.h" 10 | #import "CRNavigationBar.h" 11 | 12 | @interface CRNavigationController () 13 | 14 | @end 15 | 16 | @implementation CRNavigationController 17 | 18 | - (id)init { 19 | self = [super initWithNavigationBarClass:[CRNavigationBar class] toolbarClass:nil]; 20 | if(self) { 21 | // Custom initialization here, if needed. 22 | 23 | // To override the opacity of CRNavigationBar's barTintColor, set this value to YES. 24 | ((CRNavigationBar *)self.navigationBar).overrideOpacity = NO; 25 | } 26 | return self; 27 | } 28 | 29 | - (id)initWithRootViewController:(UIViewController *)rootViewController { 30 | self = [super initWithNavigationBarClass:[CRNavigationBar class] toolbarClass:nil]; 31 | if(self) { 32 | self.viewControllers = @[rootViewController]; 33 | 34 | // To override the opacity of CRNavigationBar's barTintColor, set this value to YES. 35 | ((CRNavigationBar *)self.navigationBar).overrideOpacity = NO; 36 | } 37 | 38 | return self; 39 | } 40 | 41 | - (UIStatusBarStyle)preferredStatusBarStyle { 42 | return UIStatusBarStyleLightContent; 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /Example/CRNavigationControllerExample/CRNavigationControllerExample-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | com.coreyroberts.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UIStatusBarStyle 32 | UIStatusBarStyleDefault 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /Example/CRNavigationControllerExample/CRNavigationControllerExample-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_3_0 10 | #warning "This project uses features only available in iOS SDK 3.0 and later." 11 | #endif 12 | 13 | #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) 14 | 15 | #ifdef __OBJC__ 16 | #import 17 | #import 18 | #endif 19 | -------------------------------------------------------------------------------- /Example/CRNavigationControllerExample/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /Example/CRNavigationControllerExample/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /Example/CRNavigationControllerExample/PrimaryViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // PrimaryViewController.h 3 | // CRNavigationControllerExample 4 | // 5 | // Created by Corey Roberts on 9/24/13. 6 | // Copyright (c) 2013 SpacePyro Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PrimaryViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/CRNavigationControllerExample/PrimaryViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // PrimaryViewController.m 3 | // CRNavigationControllerExample 4 | // 5 | // Created by Corey Roberts on 9/24/13. 6 | // Copyright (c) 2013 SpacePyro Inc. All rights reserved. 7 | // 8 | 9 | #import "PrimaryViewController.h" 10 | #import "TestViewController.h" 11 | #import "CRNavigationBar.h" 12 | #import "CRNavigationController.h" 13 | 14 | @interface PrimaryViewController () 15 | @property (nonatomic, weak) IBOutlet UIButton *redButton; 16 | @property (nonatomic, weak) IBOutlet UIButton *blueButton; 17 | @property (nonatomic, weak) IBOutlet UIButton *greenButton; 18 | @property (nonatomic, weak) IBOutlet UISlider *redSlider; 19 | @property (nonatomic, weak) IBOutlet UISlider *blueSlider; 20 | @property (nonatomic, weak) IBOutlet UISlider *greenSlider; 21 | @property (nonatomic, weak) IBOutlet UISlider *alphaSlider; 22 | @property (nonatomic, weak) IBOutlet UILabel *redValue; 23 | @property (nonatomic, weak) IBOutlet UILabel *greenValue; 24 | @property (nonatomic, weak) IBOutlet UILabel *blueValue; 25 | @property (nonatomic, weak) IBOutlet UILabel *alphaValue; 26 | @property (nonatomic, weak) IBOutlet UISegmentedControl *layerControl; 27 | @property (nonatomic, weak) IBOutlet UISegmentedControl *colorControl; 28 | 29 | - (IBAction)redButtonPressed:(id)sender; 30 | - (IBAction)blueButtonPressed:(id)sender; 31 | - (IBAction)greenButtonPressed:(id)sender; 32 | - (IBAction)slidersToggled:(id)sender; 33 | - (IBAction)layerControllerChanged:(id)sender; 34 | - (IBAction)colorControllerChanged:(id)sender; 35 | - (void)setBarTintColorWithRed:(double)red green:(double)green blue:(double)blue alpha:(double)alpha; 36 | - (void)setBackgroundColorWithRed:(double)red green:(double)green blue:(double)blue alpha:(double)alpha; 37 | - (IBAction)testConfigurationPressed:(id)sender; 38 | 39 | @end 40 | 41 | @implementation PrimaryViewController 42 | 43 | static NSArray *barTintColors = nil; 44 | static NSArray *viewBackgroundColors = nil; 45 | 46 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { 47 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 48 | if (self) { 49 | barTintColors = @[ @(0.5f), @(0.5f), @(0.5f), @(0.5f) ]; 50 | viewBackgroundColors = @[ @(1.0f), @(1.0f), @(1.0f), @(1.0f) ]; 51 | } 52 | return self; 53 | } 54 | 55 | - (void)viewDidLoad { 56 | [super viewDidLoad]; 57 | 58 | self.title = @"CRNavigationControllerExample"; 59 | 60 | self.colorControl.selectedSegmentIndex = 0; 61 | self.layerControl.selectedSegmentIndex = 1; 62 | 63 | self.redSlider.value = 0.5f; 64 | self.greenSlider.value = 0.5f; 65 | self.blueSlider.value = 0.5f; 66 | self.alphaSlider.value = 0.5f; 67 | 68 | [self slidersToggled:nil]; 69 | } 70 | 71 | - (IBAction)redButtonPressed:(id)sender { 72 | self.redSlider.value = 1.0f; 73 | self.greenSlider.value = 0.0f; 74 | self.blueSlider.value = 0.0f; 75 | self.alphaSlider.value = 1.0f; 76 | 77 | [self slidersToggled:nil]; 78 | } 79 | 80 | - (IBAction)greenButtonPressed:(id)sender { 81 | self.redSlider.value = 0.0f; 82 | self.greenSlider.value = 1.0f; 83 | self.blueSlider.value = 0.0f; 84 | self.alphaSlider.value = 1.0f; 85 | 86 | [self slidersToggled:nil]; 87 | } 88 | 89 | - (IBAction)blueButtonPressed:(id)sender { 90 | self.redSlider.value = 0.0f; 91 | self.greenSlider.value = 0.0f; 92 | self.blueSlider.value = 1.0f; 93 | self.alphaSlider.value = 1.0f; 94 | 95 | [self slidersToggled:nil]; 96 | } 97 | 98 | - (IBAction)slidersToggled:(id)sender { 99 | if(self.colorControl.selectedSegmentIndex == 0) { 100 | [self setBarTintColorWithRed:self.redSlider.value green:self.greenSlider.value blue:self.blueSlider.value alpha:self.alphaSlider.value]; 101 | } 102 | else { 103 | [self setBackgroundColorWithRed:self.redSlider.value green:self.greenSlider.value blue:self.blueSlider.value alpha:self.alphaSlider.value]; 104 | } 105 | } 106 | 107 | - (IBAction)layerControllerChanged:(id)sender { 108 | CRNavigationController *navigationController = (CRNavigationController *)self.navigationController; 109 | CRNavigationBar *navigationBar = (CRNavigationBar *)navigationController.navigationBar; 110 | 111 | [navigationBar displayColorLayer:(self.layerControl.selectedSegmentIndex == 1)]; 112 | } 113 | 114 | - (IBAction)colorControllerChanged:(id)sender { 115 | if(self.colorControl.selectedSegmentIndex == 0) { 116 | viewBackgroundColors = @[ @(self.redSlider.value), @(self.greenSlider.value), @(self.blueSlider.value), @(self.alphaSlider.value) ]; 117 | 118 | self.redSlider.value = [barTintColors[0] doubleValue]; 119 | self.greenSlider.value = [barTintColors[1] doubleValue]; 120 | self.blueSlider.value = [barTintColors[2] doubleValue]; 121 | self.alphaSlider.value = [barTintColors[3] doubleValue]; 122 | } 123 | else { 124 | barTintColors = @[ @(self.redSlider.value), @(self.greenSlider.value), @(self.blueSlider.value), @(self.alphaSlider.value) ]; 125 | 126 | self.redSlider.value = [viewBackgroundColors[0] doubleValue]; 127 | self.greenSlider.value = [viewBackgroundColors[1] doubleValue]; 128 | self.blueSlider.value = [viewBackgroundColors[2] doubleValue]; 129 | self.alphaSlider.value = [viewBackgroundColors[3] doubleValue]; 130 | } 131 | 132 | [self slidersToggled:nil]; 133 | } 134 | 135 | - (void)setBarTintColorWithRed:(double)red green:(double)green blue:(double)blue alpha:(double)alpha { 136 | UIColor *tintColor = [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; 137 | self.navigationController.navigationBar.barTintColor = tintColor; 138 | 139 | const CGFloat *components = CGColorGetComponents(tintColor.CGColor); 140 | 141 | self.redValue.text = [NSString stringWithFormat:@"%d (0x%lX)", (int)((components[0] / 1.0f) * 255), (unsigned long)((components[0] / 1.0f) * 255)]; 142 | self.greenValue.text = [NSString stringWithFormat:@"%d (0x%lX)", (int)((components[1] / 1.0f) * 255), (unsigned long)((components[1] / 1.0f) * 255)]; 143 | self.blueValue.text = [NSString stringWithFormat:@"%d (0x%lX)", (int)((components[2] / 1.0f) * 255), (unsigned long)((components[2] / 1.0f) * 255)]; 144 | self.alphaValue.text = [NSString stringWithFormat:@"%d%% (0x%lX)", (int)((CGColorGetAlpha(tintColor.CGColor) / 1.0f) * 100), (unsigned long)((components[3] / 1.0f) * 255)]; 145 | } 146 | 147 | - (void)setBackgroundColorWithRed:(double)red green:(double)green blue:(double)blue alpha:(double)alpha { 148 | UIColor *backgroundColor = [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; 149 | self.view.backgroundColor = backgroundColor; 150 | 151 | const CGFloat *components = CGColorGetComponents(backgroundColor.CGColor); 152 | 153 | self.redValue.text = [NSString stringWithFormat:@"%d", (int)((components[0] / 1.0f) * 255)]; 154 | self.greenValue.text = [NSString stringWithFormat:@"%d", (int)((components[1] / 1.0f) * 255)]; 155 | self.blueValue.text = [NSString stringWithFormat:@"%d", (int)((components[2] / 1.0f) * 255)]; 156 | self.alphaValue.text = [NSString stringWithFormat:@"%d%%", (int)((CGColorGetAlpha(backgroundColor.CGColor) / 1.0f) * 100)]; 157 | } 158 | 159 | #pragma mark - IBAction Methods 160 | 161 | - (IBAction)testConfigurationPressed:(id)sender { 162 | TestViewController *vc = [[TestViewController alloc] init]; 163 | vc.view.backgroundColor = self.view.backgroundColor; 164 | 165 | [self.navigationController pushViewController:vc animated:YES]; 166 | } 167 | 168 | @end 169 | -------------------------------------------------------------------------------- /Example/CRNavigationControllerExample/PrimaryViewController.xib: -------------------------------------------------------------------------------- 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 | 43 | 55 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 120 | 129 | 138 | 147 | 156 | 165 | 174 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | -------------------------------------------------------------------------------- /Example/CRNavigationControllerExample/TestViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TestViewController.h 3 | // CRNavigationControllerExample 4 | // 5 | // Created by Corey Roberts on 10/1/13. 6 | // Copyright (c) 2013 SpacePyro Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TestViewController : UITableViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/CRNavigationControllerExample/TestViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TestViewController.m 3 | // CRNavigationControllerExample 4 | // 5 | // Created by Corey Roberts on 10/1/13. 6 | // Copyright (c) 2013 SpacePyro Inc. All rights reserved. 7 | // 8 | 9 | #import "TestViewController.h" 10 | 11 | @interface TestViewController () 12 | 13 | @end 14 | 15 | @implementation TestViewController 16 | 17 | - (id)initWithStyle:(UITableViewStyle)style { 18 | self = [super initWithStyle:style]; 19 | if (self) { 20 | self.title = @"Configuration"; 21 | } 22 | return self; 23 | } 24 | 25 | - (void)viewDidLoad { 26 | [super viewDidLoad]; 27 | 28 | self.tableView.backgroundColor = [UIColor clearColor]; 29 | } 30 | 31 | #pragma mark - Table view data source 32 | 33 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 34 | return 5; 35 | } 36 | 37 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 38 | return 20; 39 | } 40 | 41 | - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { 42 | return [NSString stringWithFormat:@"Section %ld", (long)section]; 43 | } 44 | 45 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 46 | static NSString *CellIdentifier = @"Cell"; 47 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 48 | if(!cell) { 49 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; 50 | } 51 | 52 | cell.textLabel.text = [NSString stringWithFormat:@"[%ld, %ld] - Here's some sample text.", (long)indexPath.section, (long)indexPath.row]; 53 | cell.detailTextLabel.text = @"And here's some even better detailed text!"; 54 | cell.backgroundColor = [UIColor clearColor]; 55 | 56 | return cell; 57 | } 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /Example/CRNavigationControllerExample/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Example/CRNavigationControllerExample/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // CRNavigationControllerExample 4 | // 5 | // Created by Corey Roberts on 9/24/13. 6 | // Copyright (c) 2013 SpacePyro Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "AppDelegate.h" 12 | 13 | int main(int argc, char * argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Example/Podfile: -------------------------------------------------------------------------------- 1 | platform :ios 2 | 3 | pod "CRNavigationController", :path => "../" 4 | 5 | target "CRNavigationController" do 6 | pod "CRNavigationController" 7 | end 8 | 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any person obtaining a copy 2 | of this software and associated documentation files (the "Software"), to deal 3 | in the Software without restriction, including without limitation the rights 4 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 5 | copies of the Software, and to permit persons to whom the Software is 6 | furnished to do so, subject to the following conditions: 7 | 8 | The above copyright notice and this permission notice shall be included in 9 | all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | CRNavigationController 2 | ====================== 3 | 4 | [![Version](http://cocoapod-badges.herokuapp.com/v/CRNavigationController/badge.png)](http://cocoadocs.org/docsets/CRNavigationController) 5 | [![Platform](http://cocoapod-badges.herokuapp.com/p/CRNavigationController/badge.png)](http://cocoadocs.org/docsets/CRNavigationController) 6 | 7 | A `UINavigationController` subclass that brings about a more vivid, brighter `UINavigationBar`. 8 | 9 | **iOS 7.1 Update**: This update has yet again affected how UINavigationBar's color scheme works. This time, it seems as though any modifications to the alpha channel are ignored. This hinders this library quite a bit since we rely on editing this value to display the color layer beneath. I am currently looking for a workaround for this. 10 | 11 | **iOS 7.0.3 Update**: It seems like this update has changed the way translucency works for both navigation bars and toolbars. The blurriness is dependant on the `alpha` of the color. Unfortunately, there is no magic formula to make colors made in iOS 7.0.2 and earlier the same as they are in iOS 7.0.3. I've found that setting the alpha of the navigation bar at around `0.6f-0.8f` provides the best bang for your buck; that is, you can still obtain translucency, however, at the cost of your vibrant color. The additional color layer has been removed since this also impacts translucency, until we can figure out a more optimal solution. If you are still running an earlier version of iOS 7, this library still works! 12 | 13 | With the release of iOS 7, Apple has brought translucency all throughout the operating system. As developers, we are (in a sense) responsible for utilizing these new libraries to present unity between our apps and the OS. With the introduction of gaussian, translucent navigation bars, we are able to allow for more dynamic context with the views that we are presenting. 14 | 15 | However, there's a subtle flaw; much of the color options are rather desaturated. Suppose you wanted a translucent navigation bar that was a slightly light, rich blue. With native classes, you would get this (under a white background): 16 | 17 | ![Blue UINavigationBar without Layer](http://www.coreyjustinroberts.com/projects/CRNavigationController/blue_no_layer.png) 18 | 19 | Not exactly what you'd expect. You could come up with a combination of values for red, green, and blue and still never get the color you wanted. This is because Apple has decided to lower the saturation of the color *by about 40%*. Additionally, it inherits some color from whatever is behind it. As a result, we get this very pale blue color that isn't necessarily what we want. 20 | 21 | *Enter this library.* 22 | 23 | This library does a simple little addition to the `UINavigationBar`. By adding a layer directly above the navigation bar's background layer, we can enhance the navigation bar's vibrance. This layer takes on the same color that we specify in the navigation bar's `barTintColor`, at 50% opacity. This can be changed, but I've found that this percentage is the best blend of vibrance and translucency. With this library, we get: 24 | 25 | ![Blue UINavigationBar with Layer](http://www.coreyjustinroberts.com/projects/CRNavigationController/blue_layer.png) 26 | 27 | This still doesn't allow us to achieve an absolute color; however, it brings us **many** steps closer in the right direction. 28 | 29 | `UINavigationController` vs. `CRNavigationController`: 30 | ============================================================== 31 | 32 | Achieving a red `barTintColor`: 33 | ---------------------------------- 34 | 35 | ![Red UINavigationBar without Layer](http://www.coreyjustinroberts.com/projects/CRNavigationController/red_no_layer.png) 36 | 37 | vs. 38 | 39 | ![Red UINavigationBar with Layer](http://www.coreyjustinroberts.com/projects/CRNavigationController/red_layer.png) 40 | 41 | Achieving a black `barTintColor`: 42 | ---------------------------------- 43 | 44 | ![Black UINavigationBar without Layer](http://www.coreyjustinroberts.com/projects/CRNavigationController/black_no_layer.png) 45 | 46 | vs. 47 | 48 | ![Black UINavigationBar with Layer](http://www.coreyjustinroberts.com/projects/CRNavigationController/black_layer.png) 49 | 50 | Requirements 51 | ------------------------------------------------------------------ 52 | 53 | - Xcode 5 54 | - iOS 7.0 (iOS 7.0.3 has a different color scheme. So does iOS 7.1.) 55 | - A desire to experiment with colors! 56 | 57 | Installation 58 | ------------------------------------------------------------------ 59 | 60 | CRNavigationController is available through [CocoaPods](http://cocoapods.org). To install it, simply add the following line to your Podfile: 61 | 62 | pod "CRNavigationController" 63 | 64 | Demonstration 65 | ------------------------------------------------------------------ 66 | 67 | To run the example project, clone the repo and run `pod install` from the Example directory first. 68 | 69 | Mess with the toggles to change the color of either the `CRNavigationBar` or the `backgroundColor` of the view to understand how much impact a specific color may have on a certain `barTintColor`. RGB values in decimal and hexadecimal format are also displayed for your convenience if you decide to use this as a tool to find the perfect color. 70 | 71 | Credits, Licensing, and Other What Have You 72 | ------------------------------------------------------------------ 73 | 74 | I can't take all of the credit for this solution. This was a collaborated effort on [Stack Overflow](http://stackoverflow.com/questions/18897485/achieving-bright-vivid-colors-for-an-ios-7-translucent-uinavigationbar), created by me and many others. Feel free to use this library in your projects. Mess with the settings and find what blends work best with your apps! I only ask that you leave boilerplates unchanged and that you mention the use of this library in any apps you decide to ship into the store. 75 | 76 | I guess this goes here, too. The infamous MIT License: 77 | 78 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 79 | 80 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 81 | 82 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 83 | 84 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | desc "Runs the specs [EMPTY]" 2 | task :spec do 3 | # Provide your own implementation 4 | end 5 | 6 | task :version do 7 | git_remotes = `git remote`.strip.split("\n") 8 | 9 | if git_remotes.count > 0 10 | puts "-- fetching version number from github" 11 | sh 'git fetch' 12 | 13 | remote_version = remote_spec_version 14 | end 15 | 16 | if remote_version.nil? 17 | puts "There is no current released version. You're about to release a new Pod." 18 | version = "0.0.1" 19 | else 20 | puts "The current released version of your pod is " + 21 | remote_spec_version.to_s() 22 | version = suggested_version_number 23 | end 24 | 25 | puts "Enter the version you want to release (" + version + ") " 26 | new_version_number = $stdin.gets.strip 27 | if new_version_number == "" 28 | new_version_number = version 29 | end 30 | 31 | replace_version_number(new_version_number) 32 | end 33 | 34 | desc "Release a new version of the Pod (append repo=name to push to a private spec repo)" 35 | task :release do 36 | # Allow override of spec repo name using `repo=private` after task name 37 | repo = ENV["repo"] || "master" 38 | 39 | puts "* Running version" 40 | sh "rake version" 41 | 42 | unless ENV['SKIP_CHECKS'] 43 | if `git symbolic-ref HEAD 2>/dev/null`.strip.split('/').last != 'master' 44 | $stderr.puts "[!] You need to be on the `master' branch in order to be able to do a release." 45 | exit 1 46 | end 47 | 48 | if `git tag`.strip.split("\n").include?(spec_version) 49 | $stderr.puts "[!] A tag for version `#{spec_version}' already exists. Change the version in the podspec" 50 | exit 1 51 | end 52 | 53 | puts "You are about to release `#{spec_version}`, is that correct? [y/n]" 54 | exit if $stdin.gets.strip.downcase != 'y' 55 | end 56 | 57 | puts "* Running specs" 58 | sh "rake spec" 59 | 60 | puts "* Linting the podspec" 61 | sh "pod lib lint" 62 | 63 | # Then release 64 | sh "git commit #{podspec_path} CHANGELOG.md -m 'Release #{spec_version}' --allow-empty" 65 | sh "git tag -a #{spec_version} -m 'Release #{spec_version}'" 66 | sh "git push origin master" 67 | sh "git push origin --tags" 68 | sh "pod push #{repo} #{podspec_path}" 69 | end 70 | 71 | # @return [Pod::Version] The version as reported by the Podspec. 72 | # 73 | def spec_version 74 | require 'cocoapods' 75 | spec = Pod::Specification.from_file(podspec_path) 76 | spec.version 77 | end 78 | 79 | # @return [Pod::Version] The version as reported by the Podspec from remote. 80 | # 81 | def remote_spec_version 82 | require 'cocoapods-core' 83 | 84 | if spec_file_exist_on_remote? 85 | remote_spec = eval(`git show origin/master:#{podspec_path}`) 86 | remote_spec.version 87 | else 88 | nil 89 | end 90 | end 91 | 92 | # @return [Bool] If the remote repository has a copy of the podpesc file or not. 93 | # 94 | def spec_file_exist_on_remote? 95 | test_condition = `if git rev-parse --verify --quiet origin/master:#{podspec_path} >/dev/null; 96 | then 97 | echo 'true' 98 | else 99 | echo 'false' 100 | fi` 101 | 102 | 'true' == test_condition.strip 103 | end 104 | 105 | # @return [String] The relative path of the Podspec. 106 | # 107 | def podspec_path 108 | podspecs = Dir.glob('*.podspec') 109 | if podspecs.count == 1 110 | podspecs.first 111 | else 112 | raise "Could not select a podspec" 113 | end 114 | end 115 | 116 | # @return [String] The suggested version number based on the local and remote 117 | # version numbers. 118 | # 119 | def suggested_version_number 120 | if spec_version != remote_spec_version 121 | spec_version.to_s() 122 | else 123 | next_version(spec_version).to_s() 124 | end 125 | end 126 | 127 | # @param [Pod::Version] version 128 | # the version for which you need the next version 129 | # 130 | # @note It is computed by bumping the last component of 131 | # the version string by 1. 132 | # 133 | # @return [Pod::Version] The version that comes next after 134 | # the version supplied. 135 | # 136 | def next_version(version) 137 | version_components = version.to_s().split("."); 138 | last = (version_components.last.to_i() + 1).to_s 139 | version_components[-1] = last 140 | Pod::Version.new(version_components.join(".")) 141 | end 142 | 143 | # @param [String] new_version_number 144 | # the new version number 145 | # 146 | # @note This methods replaces the version number in the podspec file 147 | # with a new version number. 148 | # 149 | # @return void 150 | # 151 | def replace_version_number(new_version_number) 152 | text = File.read(podspec_path) 153 | text.gsub!(/(s.version( )*= ")#{spec_version}(")/, 154 | "\\1#{new_version_number}\\3") 155 | File.open(podspec_path, "w") { |file| file.puts text } 156 | end 157 | --------------------------------------------------------------------------------