├── .DS_Store ├── DSNavigationBar ├── .DS_Store ├── DSNavigationBar.h └── DSNavigationBar.m ├── Demo ├── .DS_Store ├── DSTranparentNavigationBar.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── DSTranparentNavigationBar.xccheckout │ │ └── xcuserdata │ │ │ └── diegoserranoa.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── diegoserranoa.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ ├── DSTranparentNavigationBar.xcscheme │ │ └── xcschememanagement.plist ├── DSTranparentNavigationBar │ ├── .DS_Store │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── DSNavigationBar.h │ ├── DSNavigationBar.m │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── guayaquil.imageset │ │ │ ├── Contents.json │ │ │ └── guayaquil.jpg │ │ └── quito.imageset │ │ │ ├── Contents.json │ │ │ └── quito.jpg │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ └── main.m └── DSTranparentNavigationBarTests │ ├── DSTranparentNavigationBarTests.m │ └── Info.plist ├── LICENSE ├── README.md └── img ├── alpha0.png ├── alpha05.png ├── gradientalpha.png └── ib.png /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diegoserranoa/DSTransparentNavigationBar/39ac42575fa1dc45764a866dc72129a8ce46fc06/.DS_Store -------------------------------------------------------------------------------- /DSNavigationBar/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diegoserranoa/DSTransparentNavigationBar/39ac42575fa1dc45764a866dc72129a8ce46fc06/DSNavigationBar/.DS_Store -------------------------------------------------------------------------------- /DSNavigationBar/DSNavigationBar.h: -------------------------------------------------------------------------------- 1 | // 2 | // DSNavigationBar.h 3 | // DSTranparentNavigationBar 4 | // 5 | // Created by Diego Serrano on 10/13/14. 6 | // Copyright (c) 2014 Diego Serrano. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | IB_DESIGNABLE 12 | 13 | @interface DSNavigationBar : UINavigationBar 14 | 15 | @property (strong, nonatomic) IBInspectable UIColor *color; 16 | 17 | -(void)setNavigationBarWithColor:(UIColor *)color; 18 | -(void)setNavigationBarWithColors:(NSArray *)colours; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /DSNavigationBar/DSNavigationBar.m: -------------------------------------------------------------------------------- 1 | // 2 | // DSNavigationBar.m 3 | // DSTranparentNavigationBar 4 | // 5 | // Created by Diego Serrano on 10/13/14. 6 | // Copyright (c) 2014 Diego Serrano. All rights reserved. 7 | // 8 | 9 | #import "DSNavigationBar.h" 10 | #import 11 | 12 | @implementation DSNavigationBar 13 | 14 | static CGFloat kEndPoint = 1.5; 15 | 16 | -(void)awakeFromNib 17 | { 18 | [super awakeFromNib]; 19 | if (self.color) { 20 | [self setNavigationBarWithColor:self.color]; 21 | } else { 22 | [self setNavigationBarWithColor:[UIColor whiteColor]]; 23 | } 24 | } 25 | 26 | /* 27 | - (id)initWithCoder:(NSCoder *)aDecoder { 28 | 29 | self = [super initWithCoder:aDecoder]; 30 | 31 | if (self) { 32 | if (self.color) { 33 | [self setNavigationBarWithColor:self.color]; 34 | } else { 35 | [self setNavigationBarWithColor:[UIColor whiteColor]]; 36 | } 37 | 38 | return self; 39 | } 40 | 41 | -(id)initWithFrame:(CGRect)frame 42 | { 43 | self = [super initWithFrame:frame]; 44 | 45 | if (self) { 46 | if (self.color) { 47 | [self setNavigationBarWithColor:self.color]; 48 | } else { 49 | [self setNavigationBarWithColor:[UIColor whiteColor]]; 50 | } 51 | } 52 | 53 | return self; 54 | } 55 | */ 56 | void drawLinearGradient(CGContextRef context, CGRect rect, CGColorRef startColor, CGColorRef endColor) 57 | { 58 | CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 59 | CGFloat locations[] = { 0.0, 1.0 }; 60 | 61 | NSArray *colors = @[(__bridge id) startColor, (__bridge id) endColor]; 62 | 63 | CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (__bridge CFArrayRef) colors, locations); 64 | CGPoint startPoint = CGPointMake(rect.size.width/2, 0); 65 | CGPoint endPoint = CGPointMake(rect.size.width/2, rect.size.height/kEndPoint); 66 | 67 | CGContextSaveGState(context); 68 | CGContextAddRect(context, rect); 69 | CGContextClip(context); 70 | CGContextDrawLinearGradient(context, gradient, startPoint, endPoint, 0); 71 | CGContextSetStrokeColorWithColor(context, [[UIColor clearColor] CGColor]); 72 | } 73 | 74 | - (UIImage *)imageWithColor:(UIColor *)color 75 | { 76 | CGRect rect = CGRectMake(0, 0, 1, 1); 77 | UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0); 78 | [color setFill]; 79 | UIRectFill(rect); 80 | 81 | UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 82 | UIGraphicsEndImageContext(); 83 | 84 | return image; 85 | } 86 | 87 | - (UIImage *)imageWithGradients:(NSArray *)colours 88 | { 89 | CGRect rect = CGRectMake(0, 0, 1, 1); 90 | UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0); 91 | CGContextRef context = UIGraphicsGetCurrentContext(); 92 | UIColor * beginColor = [colours objectAtIndex:0]; 93 | UIColor * endColor = [colours objectAtIndex:1]; 94 | drawLinearGradient(context, rect, beginColor.CGColor, endColor.CGColor); 95 | CGContextRestoreGState(context); 96 | 97 | UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 98 | UIGraphicsEndImageContext(); 99 | 100 | return image; 101 | } 102 | 103 | -(void)setNavigationBarWithColor:(UIColor *)color 104 | { 105 | UIImage *image = [self imageWithColor:color]; 106 | 107 | [self setBackgroundImage:image forBarMetrics:UIBarMetricsDefault]; 108 | [self setBarStyle:UIBarStyleDefault]; 109 | [self setShadowImage:[UIImage new]]; 110 | [self setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]}]; 111 | [self setTintColor:[UIColor whiteColor]]; 112 | [self setTranslucent:YES]; 113 | 114 | } 115 | 116 | -(void)setNavigationBarWithColors:(NSArray *)colours 117 | { 118 | UIImage *image = [self imageWithGradients:colours]; 119 | 120 | [self setBackgroundImage:image forBarMetrics:UIBarMetricsDefault]; 121 | [self setBarStyle:UIBarStyleDefault]; 122 | [self setShadowImage:[UIImage new]]; 123 | [self setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]}]; 124 | [self setTintColor:[UIColor whiteColor]]; 125 | [self setTranslucent:YES]; 126 | } 127 | 128 | 129 | @end 130 | -------------------------------------------------------------------------------- /Demo/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diegoserranoa/DSTransparentNavigationBar/39ac42575fa1dc45764a866dc72129a8ce46fc06/Demo/.DS_Store -------------------------------------------------------------------------------- /Demo/DSTranparentNavigationBar.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 7E9593A619ECC456000397B6 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E9593A519ECC456000397B6 /* main.m */; }; 11 | 7E9593A919ECC456000397B6 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E9593A819ECC456000397B6 /* AppDelegate.m */; }; 12 | 7E9593AC19ECC456000397B6 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E9593AB19ECC456000397B6 /* ViewController.m */; }; 13 | 7E9593AF19ECC456000397B6 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7E9593AD19ECC456000397B6 /* Main.storyboard */; }; 14 | 7E9593B119ECC456000397B6 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7E9593B019ECC456000397B6 /* Images.xcassets */; }; 15 | 7E9593B419ECC456000397B6 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7E9593B219ECC456000397B6 /* LaunchScreen.xib */; }; 16 | 7E9593C019ECC456000397B6 /* DSTranparentNavigationBarTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E9593BF19ECC456000397B6 /* DSTranparentNavigationBarTests.m */; }; 17 | 7EF8833719ECECDC00729F36 /* DSNavigationBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 7EF8833619ECECDC00729F36 /* DSNavigationBar.m */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | 7E9593BA19ECC456000397B6 /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = 7E95939819ECC456000397B6 /* Project object */; 24 | proxyType = 1; 25 | remoteGlobalIDString = 7E95939F19ECC456000397B6; 26 | remoteInfo = DSTranparentNavigationBar; 27 | }; 28 | /* End PBXContainerItemProxy section */ 29 | 30 | /* Begin PBXFileReference section */ 31 | 7E9593A019ECC456000397B6 /* DSTranparentNavigationBar.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DSTranparentNavigationBar.app; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | 7E9593A419ECC456000397B6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 33 | 7E9593A519ECC456000397B6 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 34 | 7E9593A719ECC456000397B6 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 35 | 7E9593A819ECC456000397B6 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 36 | 7E9593AA19ECC456000397B6 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 37 | 7E9593AB19ECC456000397B6 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 38 | 7E9593AE19ECC456000397B6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 39 | 7E9593B019ECC456000397B6 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 40 | 7E9593B319ECC456000397B6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 41 | 7E9593B919ECC456000397B6 /* DSTranparentNavigationBarTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DSTranparentNavigationBarTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | 7E9593BE19ECC456000397B6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 43 | 7E9593BF19ECC456000397B6 /* DSTranparentNavigationBarTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DSTranparentNavigationBarTests.m; sourceTree = ""; }; 44 | 7EF8833519ECECDC00729F36 /* DSNavigationBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DSNavigationBar.h; sourceTree = ""; }; 45 | 7EF8833619ECECDC00729F36 /* DSNavigationBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DSNavigationBar.m; sourceTree = ""; }; 46 | /* End PBXFileReference section */ 47 | 48 | /* Begin PBXFrameworksBuildPhase section */ 49 | 7E95939D19ECC456000397B6 /* Frameworks */ = { 50 | isa = PBXFrameworksBuildPhase; 51 | buildActionMask = 2147483647; 52 | files = ( 53 | ); 54 | runOnlyForDeploymentPostprocessing = 0; 55 | }; 56 | 7E9593B619ECC456000397B6 /* Frameworks */ = { 57 | isa = PBXFrameworksBuildPhase; 58 | buildActionMask = 2147483647; 59 | files = ( 60 | ); 61 | runOnlyForDeploymentPostprocessing = 0; 62 | }; 63 | /* End PBXFrameworksBuildPhase section */ 64 | 65 | /* Begin PBXGroup section */ 66 | 7E95939719ECC456000397B6 = { 67 | isa = PBXGroup; 68 | children = ( 69 | 7E9593A219ECC456000397B6 /* DSTranparentNavigationBar */, 70 | 7E9593BC19ECC456000397B6 /* DSTranparentNavigationBarTests */, 71 | 7E9593A119ECC456000397B6 /* Products */, 72 | ); 73 | sourceTree = ""; 74 | }; 75 | 7E9593A119ECC456000397B6 /* Products */ = { 76 | isa = PBXGroup; 77 | children = ( 78 | 7E9593A019ECC456000397B6 /* DSTranparentNavigationBar.app */, 79 | 7E9593B919ECC456000397B6 /* DSTranparentNavigationBarTests.xctest */, 80 | ); 81 | name = Products; 82 | sourceTree = ""; 83 | }; 84 | 7E9593A219ECC456000397B6 /* DSTranparentNavigationBar */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | 7E9593C919ECC46D000397B6 /* DSTranparentNavigationBar */, 88 | 7E9593A719ECC456000397B6 /* AppDelegate.h */, 89 | 7E9593A819ECC456000397B6 /* AppDelegate.m */, 90 | 7E9593AA19ECC456000397B6 /* ViewController.h */, 91 | 7E9593AB19ECC456000397B6 /* ViewController.m */, 92 | 7E9593AD19ECC456000397B6 /* Main.storyboard */, 93 | 7E9593B019ECC456000397B6 /* Images.xcassets */, 94 | 7E9593B219ECC456000397B6 /* LaunchScreen.xib */, 95 | 7E9593A319ECC456000397B6 /* Supporting Files */, 96 | ); 97 | path = DSTranparentNavigationBar; 98 | sourceTree = ""; 99 | }; 100 | 7E9593A319ECC456000397B6 /* Supporting Files */ = { 101 | isa = PBXGroup; 102 | children = ( 103 | 7E9593A419ECC456000397B6 /* Info.plist */, 104 | 7E9593A519ECC456000397B6 /* main.m */, 105 | ); 106 | name = "Supporting Files"; 107 | sourceTree = ""; 108 | }; 109 | 7E9593BC19ECC456000397B6 /* DSTranparentNavigationBarTests */ = { 110 | isa = PBXGroup; 111 | children = ( 112 | 7E9593BF19ECC456000397B6 /* DSTranparentNavigationBarTests.m */, 113 | 7E9593BD19ECC456000397B6 /* Supporting Files */, 114 | ); 115 | path = DSTranparentNavigationBarTests; 116 | sourceTree = ""; 117 | }; 118 | 7E9593BD19ECC456000397B6 /* Supporting Files */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | 7E9593BE19ECC456000397B6 /* Info.plist */, 122 | ); 123 | name = "Supporting Files"; 124 | sourceTree = ""; 125 | }; 126 | 7E9593C919ECC46D000397B6 /* DSTranparentNavigationBar */ = { 127 | isa = PBXGroup; 128 | children = ( 129 | 7EF8833519ECECDC00729F36 /* DSNavigationBar.h */, 130 | 7EF8833619ECECDC00729F36 /* DSNavigationBar.m */, 131 | ); 132 | name = DSTranparentNavigationBar; 133 | sourceTree = ""; 134 | }; 135 | /* End PBXGroup section */ 136 | 137 | /* Begin PBXNativeTarget section */ 138 | 7E95939F19ECC456000397B6 /* DSTranparentNavigationBar */ = { 139 | isa = PBXNativeTarget; 140 | buildConfigurationList = 7E9593C319ECC456000397B6 /* Build configuration list for PBXNativeTarget "DSTranparentNavigationBar" */; 141 | buildPhases = ( 142 | 7E95939C19ECC456000397B6 /* Sources */, 143 | 7E95939D19ECC456000397B6 /* Frameworks */, 144 | 7E95939E19ECC456000397B6 /* Resources */, 145 | ); 146 | buildRules = ( 147 | ); 148 | dependencies = ( 149 | ); 150 | name = DSTranparentNavigationBar; 151 | productName = DSTranparentNavigationBar; 152 | productReference = 7E9593A019ECC456000397B6 /* DSTranparentNavigationBar.app */; 153 | productType = "com.apple.product-type.application"; 154 | }; 155 | 7E9593B819ECC456000397B6 /* DSTranparentNavigationBarTests */ = { 156 | isa = PBXNativeTarget; 157 | buildConfigurationList = 7E9593C619ECC456000397B6 /* Build configuration list for PBXNativeTarget "DSTranparentNavigationBarTests" */; 158 | buildPhases = ( 159 | 7E9593B519ECC456000397B6 /* Sources */, 160 | 7E9593B619ECC456000397B6 /* Frameworks */, 161 | 7E9593B719ECC456000397B6 /* Resources */, 162 | ); 163 | buildRules = ( 164 | ); 165 | dependencies = ( 166 | 7E9593BB19ECC456000397B6 /* PBXTargetDependency */, 167 | ); 168 | name = DSTranparentNavigationBarTests; 169 | productName = DSTranparentNavigationBarTests; 170 | productReference = 7E9593B919ECC456000397B6 /* DSTranparentNavigationBarTests.xctest */; 171 | productType = "com.apple.product-type.bundle.unit-test"; 172 | }; 173 | /* End PBXNativeTarget section */ 174 | 175 | /* Begin PBXProject section */ 176 | 7E95939819ECC456000397B6 /* Project object */ = { 177 | isa = PBXProject; 178 | attributes = { 179 | LastUpgradeCheck = 0600; 180 | ORGANIZATIONNAME = "Diego Serrano"; 181 | TargetAttributes = { 182 | 7E95939F19ECC456000397B6 = { 183 | CreatedOnToolsVersion = 6.0.1; 184 | }; 185 | 7E9593B819ECC456000397B6 = { 186 | CreatedOnToolsVersion = 6.0.1; 187 | TestTargetID = 7E95939F19ECC456000397B6; 188 | }; 189 | }; 190 | }; 191 | buildConfigurationList = 7E95939B19ECC456000397B6 /* Build configuration list for PBXProject "DSTranparentNavigationBar" */; 192 | compatibilityVersion = "Xcode 3.2"; 193 | developmentRegion = English; 194 | hasScannedForEncodings = 0; 195 | knownRegions = ( 196 | en, 197 | Base, 198 | ); 199 | mainGroup = 7E95939719ECC456000397B6; 200 | productRefGroup = 7E9593A119ECC456000397B6 /* Products */; 201 | projectDirPath = ""; 202 | projectRoot = ""; 203 | targets = ( 204 | 7E95939F19ECC456000397B6 /* DSTranparentNavigationBar */, 205 | 7E9593B819ECC456000397B6 /* DSTranparentNavigationBarTests */, 206 | ); 207 | }; 208 | /* End PBXProject section */ 209 | 210 | /* Begin PBXResourcesBuildPhase section */ 211 | 7E95939E19ECC456000397B6 /* Resources */ = { 212 | isa = PBXResourcesBuildPhase; 213 | buildActionMask = 2147483647; 214 | files = ( 215 | 7E9593AF19ECC456000397B6 /* Main.storyboard in Resources */, 216 | 7E9593B419ECC456000397B6 /* LaunchScreen.xib in Resources */, 217 | 7E9593B119ECC456000397B6 /* Images.xcassets in Resources */, 218 | ); 219 | runOnlyForDeploymentPostprocessing = 0; 220 | }; 221 | 7E9593B719ECC456000397B6 /* Resources */ = { 222 | isa = PBXResourcesBuildPhase; 223 | buildActionMask = 2147483647; 224 | files = ( 225 | ); 226 | runOnlyForDeploymentPostprocessing = 0; 227 | }; 228 | /* End PBXResourcesBuildPhase section */ 229 | 230 | /* Begin PBXSourcesBuildPhase section */ 231 | 7E95939C19ECC456000397B6 /* Sources */ = { 232 | isa = PBXSourcesBuildPhase; 233 | buildActionMask = 2147483647; 234 | files = ( 235 | 7E9593AC19ECC456000397B6 /* ViewController.m in Sources */, 236 | 7E9593A919ECC456000397B6 /* AppDelegate.m in Sources */, 237 | 7EF8833719ECECDC00729F36 /* DSNavigationBar.m in Sources */, 238 | 7E9593A619ECC456000397B6 /* main.m in Sources */, 239 | ); 240 | runOnlyForDeploymentPostprocessing = 0; 241 | }; 242 | 7E9593B519ECC456000397B6 /* Sources */ = { 243 | isa = PBXSourcesBuildPhase; 244 | buildActionMask = 2147483647; 245 | files = ( 246 | 7E9593C019ECC456000397B6 /* DSTranparentNavigationBarTests.m in Sources */, 247 | ); 248 | runOnlyForDeploymentPostprocessing = 0; 249 | }; 250 | /* End PBXSourcesBuildPhase section */ 251 | 252 | /* Begin PBXTargetDependency section */ 253 | 7E9593BB19ECC456000397B6 /* PBXTargetDependency */ = { 254 | isa = PBXTargetDependency; 255 | target = 7E95939F19ECC456000397B6 /* DSTranparentNavigationBar */; 256 | targetProxy = 7E9593BA19ECC456000397B6 /* PBXContainerItemProxy */; 257 | }; 258 | /* End PBXTargetDependency section */ 259 | 260 | /* Begin PBXVariantGroup section */ 261 | 7E9593AD19ECC456000397B6 /* Main.storyboard */ = { 262 | isa = PBXVariantGroup; 263 | children = ( 264 | 7E9593AE19ECC456000397B6 /* Base */, 265 | ); 266 | name = Main.storyboard; 267 | sourceTree = ""; 268 | }; 269 | 7E9593B219ECC456000397B6 /* LaunchScreen.xib */ = { 270 | isa = PBXVariantGroup; 271 | children = ( 272 | 7E9593B319ECC456000397B6 /* Base */, 273 | ); 274 | name = LaunchScreen.xib; 275 | sourceTree = ""; 276 | }; 277 | /* End PBXVariantGroup section */ 278 | 279 | /* Begin XCBuildConfiguration section */ 280 | 7E9593C119ECC456000397B6 /* Debug */ = { 281 | isa = XCBuildConfiguration; 282 | buildSettings = { 283 | ALWAYS_SEARCH_USER_PATHS = NO; 284 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 285 | CLANG_CXX_LIBRARY = "libc++"; 286 | CLANG_ENABLE_MODULES = YES; 287 | CLANG_ENABLE_OBJC_ARC = YES; 288 | CLANG_WARN_BOOL_CONVERSION = YES; 289 | CLANG_WARN_CONSTANT_CONVERSION = YES; 290 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 291 | CLANG_WARN_EMPTY_BODY = YES; 292 | CLANG_WARN_ENUM_CONVERSION = YES; 293 | CLANG_WARN_INT_CONVERSION = YES; 294 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 295 | CLANG_WARN_UNREACHABLE_CODE = YES; 296 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 297 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 298 | COPY_PHASE_STRIP = NO; 299 | ENABLE_STRICT_OBJC_MSGSEND = YES; 300 | GCC_C_LANGUAGE_STANDARD = gnu99; 301 | GCC_DYNAMIC_NO_PIC = NO; 302 | GCC_OPTIMIZATION_LEVEL = 0; 303 | GCC_PREPROCESSOR_DEFINITIONS = ( 304 | "DEBUG=1", 305 | "$(inherited)", 306 | ); 307 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 308 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 309 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 310 | GCC_WARN_UNDECLARED_SELECTOR = YES; 311 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 312 | GCC_WARN_UNUSED_FUNCTION = YES; 313 | GCC_WARN_UNUSED_VARIABLE = YES; 314 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 315 | MTL_ENABLE_DEBUG_INFO = YES; 316 | ONLY_ACTIVE_ARCH = YES; 317 | SDKROOT = iphoneos; 318 | TARGETED_DEVICE_FAMILY = "1,2"; 319 | }; 320 | name = Debug; 321 | }; 322 | 7E9593C219ECC456000397B6 /* Release */ = { 323 | isa = XCBuildConfiguration; 324 | buildSettings = { 325 | ALWAYS_SEARCH_USER_PATHS = NO; 326 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 327 | CLANG_CXX_LIBRARY = "libc++"; 328 | CLANG_ENABLE_MODULES = YES; 329 | CLANG_ENABLE_OBJC_ARC = YES; 330 | CLANG_WARN_BOOL_CONVERSION = YES; 331 | CLANG_WARN_CONSTANT_CONVERSION = YES; 332 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 333 | CLANG_WARN_EMPTY_BODY = YES; 334 | CLANG_WARN_ENUM_CONVERSION = YES; 335 | CLANG_WARN_INT_CONVERSION = YES; 336 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 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 = YES; 341 | ENABLE_NS_ASSERTIONS = NO; 342 | ENABLE_STRICT_OBJC_MSGSEND = YES; 343 | GCC_C_LANGUAGE_STANDARD = gnu99; 344 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 345 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 346 | GCC_WARN_UNDECLARED_SELECTOR = YES; 347 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 348 | GCC_WARN_UNUSED_FUNCTION = YES; 349 | GCC_WARN_UNUSED_VARIABLE = YES; 350 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 351 | MTL_ENABLE_DEBUG_INFO = NO; 352 | SDKROOT = iphoneos; 353 | TARGETED_DEVICE_FAMILY = "1,2"; 354 | VALIDATE_PRODUCT = YES; 355 | }; 356 | name = Release; 357 | }; 358 | 7E9593C419ECC456000397B6 /* Debug */ = { 359 | isa = XCBuildConfiguration; 360 | buildSettings = { 361 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 362 | INFOPLIST_FILE = DSTranparentNavigationBar/Info.plist; 363 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 364 | PRODUCT_NAME = "$(TARGET_NAME)"; 365 | }; 366 | name = Debug; 367 | }; 368 | 7E9593C519ECC456000397B6 /* Release */ = { 369 | isa = XCBuildConfiguration; 370 | buildSettings = { 371 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 372 | INFOPLIST_FILE = DSTranparentNavigationBar/Info.plist; 373 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 374 | PRODUCT_NAME = "$(TARGET_NAME)"; 375 | }; 376 | name = Release; 377 | }; 378 | 7E9593C719ECC456000397B6 /* Debug */ = { 379 | isa = XCBuildConfiguration; 380 | buildSettings = { 381 | BUNDLE_LOADER = "$(TEST_HOST)"; 382 | FRAMEWORK_SEARCH_PATHS = ( 383 | "$(SDKROOT)/Developer/Library/Frameworks", 384 | "$(inherited)", 385 | ); 386 | GCC_PREPROCESSOR_DEFINITIONS = ( 387 | "DEBUG=1", 388 | "$(inherited)", 389 | ); 390 | INFOPLIST_FILE = DSTranparentNavigationBarTests/Info.plist; 391 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 392 | PRODUCT_NAME = "$(TARGET_NAME)"; 393 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DSTranparentNavigationBar.app/DSTranparentNavigationBar"; 394 | }; 395 | name = Debug; 396 | }; 397 | 7E9593C819ECC456000397B6 /* Release */ = { 398 | isa = XCBuildConfiguration; 399 | buildSettings = { 400 | BUNDLE_LOADER = "$(TEST_HOST)"; 401 | FRAMEWORK_SEARCH_PATHS = ( 402 | "$(SDKROOT)/Developer/Library/Frameworks", 403 | "$(inherited)", 404 | ); 405 | INFOPLIST_FILE = DSTranparentNavigationBarTests/Info.plist; 406 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 407 | PRODUCT_NAME = "$(TARGET_NAME)"; 408 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DSTranparentNavigationBar.app/DSTranparentNavigationBar"; 409 | }; 410 | name = Release; 411 | }; 412 | /* End XCBuildConfiguration section */ 413 | 414 | /* Begin XCConfigurationList section */ 415 | 7E95939B19ECC456000397B6 /* Build configuration list for PBXProject "DSTranparentNavigationBar" */ = { 416 | isa = XCConfigurationList; 417 | buildConfigurations = ( 418 | 7E9593C119ECC456000397B6 /* Debug */, 419 | 7E9593C219ECC456000397B6 /* Release */, 420 | ); 421 | defaultConfigurationIsVisible = 0; 422 | defaultConfigurationName = Release; 423 | }; 424 | 7E9593C319ECC456000397B6 /* Build configuration list for PBXNativeTarget "DSTranparentNavigationBar" */ = { 425 | isa = XCConfigurationList; 426 | buildConfigurations = ( 427 | 7E9593C419ECC456000397B6 /* Debug */, 428 | 7E9593C519ECC456000397B6 /* Release */, 429 | ); 430 | defaultConfigurationIsVisible = 0; 431 | defaultConfigurationName = Release; 432 | }; 433 | 7E9593C619ECC456000397B6 /* Build configuration list for PBXNativeTarget "DSTranparentNavigationBarTests" */ = { 434 | isa = XCConfigurationList; 435 | buildConfigurations = ( 436 | 7E9593C719ECC456000397B6 /* Debug */, 437 | 7E9593C819ECC456000397B6 /* Release */, 438 | ); 439 | defaultConfigurationIsVisible = 0; 440 | defaultConfigurationName = Release; 441 | }; 442 | /* End XCConfigurationList section */ 443 | }; 444 | rootObject = 7E95939819ECC456000397B6 /* Project object */; 445 | } 446 | -------------------------------------------------------------------------------- /Demo/DSTranparentNavigationBar.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Demo/DSTranparentNavigationBar.xcodeproj/project.xcworkspace/xcshareddata/DSTranparentNavigationBar.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 96BC023A-07BE-4DE6-8A91-6DAA754D1339 9 | IDESourceControlProjectName 10 | DSTranparentNavigationBar 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 8975EBE8A02EF02EDFE5027C6931BFB1C6715C06 14 | https://github.com/diegoserranoa/DSTransparentNavigationBar.git 15 | 16 | IDESourceControlProjectPath 17 | Demo/DSTranparentNavigationBar.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 8975EBE8A02EF02EDFE5027C6931BFB1C6715C06 21 | ../../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/diegoserranoa/DSTransparentNavigationBar.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 8975EBE8A02EF02EDFE5027C6931BFB1C6715C06 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 8975EBE8A02EF02EDFE5027C6931BFB1C6715C06 36 | IDESourceControlWCCName 37 | DSTranparentNavigationBar 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Demo/DSTranparentNavigationBar.xcodeproj/project.xcworkspace/xcuserdata/diegoserranoa.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diegoserranoa/DSTransparentNavigationBar/39ac42575fa1dc45764a866dc72129a8ce46fc06/Demo/DSTranparentNavigationBar.xcodeproj/project.xcworkspace/xcuserdata/diegoserranoa.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Demo/DSTranparentNavigationBar.xcodeproj/xcuserdata/diegoserranoa.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Demo/DSTranparentNavigationBar.xcodeproj/xcuserdata/diegoserranoa.xcuserdatad/xcschemes/DSTranparentNavigationBar.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 94 | 100 | 101 | 102 | 103 | 105 | 106 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /Demo/DSTranparentNavigationBar.xcodeproj/xcuserdata/diegoserranoa.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | DSTranparentNavigationBar.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 7E95939F19ECC456000397B6 16 | 17 | primary 18 | 19 | 20 | 7E9593B819ECC456000397B6 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Demo/DSTranparentNavigationBar/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diegoserranoa/DSTransparentNavigationBar/39ac42575fa1dc45764a866dc72129a8ce46fc06/Demo/DSTranparentNavigationBar/.DS_Store -------------------------------------------------------------------------------- /Demo/DSTranparentNavigationBar/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // DSTranparentNavigationBar 4 | // 5 | // Created by Diego Serrano on 10/13/14. 6 | // Copyright (c) 2014 Diego Serrano. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /Demo/DSTranparentNavigationBar/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // DSTranparentNavigationBar 4 | // 5 | // Created by Diego Serrano on 10/13/14. 6 | // Copyright (c) 2014 Diego Serrano. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "DSNavigationBar.h" 11 | #import "ViewController.h" 12 | 13 | @interface AppDelegate () 14 | 15 | @end 16 | 17 | @implementation AppDelegate 18 | 19 | 20 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 21 | // Override point for customization after application launch. 22 | UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" 23 | bundle: nil]; 24 | /* 25 | UINavigationController *navigationController = [[UINavigationController alloc] initWithNavigationBarClass:[DSNavigationBar class] toolbarClass:nil]; 26 | 27 | UIColor * color = [UIColor colorWithRed:(190/255.0) green:(218/255.0) blue:(218/255) alpha:0.5f]; 28 | [[DSNavigationBar appearance] setNavigationBarWithColor:color]; 29 | 30 | 31 | UIColor *topColor = [UIColor colorWithRed:(190/255.0) green:(218/255.0) blue:(218/255) alpha:1.0f]; 32 | UIColor *bottomColor = [UIColor colorWithRed:(190/255.0) green:(218/255.0) blue:(218/255) alpha:0]; 33 | [[DSNavigationBar appearance] setNavigationBarWithColors:@[topColor,bottomColor]]; 34 | 35 | 36 | UIViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"initial"]; 37 | [navigationController setViewControllers:@[vc]]; 38 | [self.window setRootViewController:navigationController]; 39 | */ 40 | return YES; 41 | } 42 | 43 | - (void)applicationWillResignActive:(UIApplication *)application { 44 | // 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. 45 | // 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. 46 | } 47 | 48 | - (void)applicationDidEnterBackground:(UIApplication *)application { 49 | // 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. 50 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 51 | } 52 | 53 | - (void)applicationWillEnterForeground:(UIApplication *)application { 54 | // 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. 55 | } 56 | 57 | - (void)applicationDidBecomeActive:(UIApplication *)application { 58 | // 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. 59 | } 60 | 61 | - (void)applicationWillTerminate:(UIApplication *)application { 62 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 63 | } 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /Demo/DSTranparentNavigationBar/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Demo/DSTranparentNavigationBar/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 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 | 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 | -------------------------------------------------------------------------------- /Demo/DSTranparentNavigationBar/DSNavigationBar.h: -------------------------------------------------------------------------------- 1 | // 2 | // DSNavigationBar.h 3 | // DSTranparentNavigationBar 4 | // 5 | // Created by Diego Serrano on 10/13/14. 6 | // Copyright (c) 2014 Diego Serrano. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | IB_DESIGNABLE 12 | 13 | @interface DSNavigationBar : UINavigationBar 14 | 15 | @property (strong, nonatomic) IBInspectable UIColor *color; 16 | 17 | -(void)setNavigationBarWithColor:(UIColor *)color; 18 | -(void)setNavigationBarWithColors:(NSArray *)colours; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Demo/DSTranparentNavigationBar/DSNavigationBar.m: -------------------------------------------------------------------------------- 1 | // 2 | // DSNavigationBar.m 3 | // DSTranparentNavigationBar 4 | // 5 | // Created by Diego Serrano on 10/13/14. 6 | // Copyright (c) 2014 Diego Serrano. All rights reserved. 7 | // 8 | 9 | #import "DSNavigationBar.h" 10 | #import 11 | 12 | @implementation DSNavigationBar 13 | 14 | static CGFloat kEndPoint = 1.5; 15 | 16 | -(void)awakeFromNib 17 | { 18 | [super awakeFromNib]; 19 | if (self.color) { 20 | [self setNavigationBarWithColor:self.color]; 21 | } else { 22 | [self setNavigationBarWithColor:[UIColor whiteColor]]; 23 | } 24 | } 25 | 26 | /* 27 | - (id)initWithCoder:(NSCoder *)aDecoder { 28 | 29 | self = [super initWithCoder:aDecoder]; 30 | 31 | if (self) { 32 | if (self.color) { 33 | [self setNavigationBarWithColor:self.color]; 34 | } else { 35 | [self setNavigationBarWithColor:[UIColor whiteColor]]; 36 | } 37 | 38 | return self; 39 | } 40 | 41 | -(id)initWithFrame:(CGRect)frame 42 | { 43 | self = [super initWithFrame:frame]; 44 | 45 | if (self) { 46 | if (self.color) { 47 | [self setNavigationBarWithColor:self.color]; 48 | } else { 49 | [self setNavigationBarWithColor:[UIColor whiteColor]]; 50 | } 51 | } 52 | 53 | return self; 54 | } 55 | */ 56 | void drawLinearGradient(CGContextRef context, CGRect rect, CGColorRef startColor, CGColorRef endColor) 57 | { 58 | CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 59 | CGFloat locations[] = { 0.0, 1.0 }; 60 | 61 | NSArray *colors = @[(__bridge id) startColor, (__bridge id) endColor]; 62 | 63 | CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (__bridge CFArrayRef) colors, locations); 64 | CGPoint startPoint = CGPointMake(rect.size.width/2, 0); 65 | CGPoint endPoint = CGPointMake(rect.size.width/2, rect.size.height/kEndPoint); 66 | 67 | CGContextSaveGState(context); 68 | CGContextAddRect(context, rect); 69 | CGContextClip(context); 70 | CGContextDrawLinearGradient(context, gradient, startPoint, endPoint, 0); 71 | CGContextSetStrokeColorWithColor(context, [[UIColor clearColor] CGColor]); 72 | } 73 | 74 | - (UIImage *)imageWithColor:(UIColor *)color 75 | { 76 | CGRect rect = CGRectMake(0, 0, 1, 1); 77 | UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0); 78 | [color setFill]; 79 | UIRectFill(rect); 80 | 81 | UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 82 | UIGraphicsEndImageContext(); 83 | 84 | return image; 85 | } 86 | 87 | - (UIImage *)imageWithGradients:(NSArray *)colours 88 | { 89 | CGRect rect = CGRectMake(0, 0, 1, 1); 90 | UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0); 91 | CGContextRef context = UIGraphicsGetCurrentContext(); 92 | UIColor * beginColor = [colours objectAtIndex:0]; 93 | UIColor * endColor = [colours objectAtIndex:1]; 94 | drawLinearGradient(context, rect, beginColor.CGColor, endColor.CGColor); 95 | CGContextRestoreGState(context); 96 | 97 | UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 98 | UIGraphicsEndImageContext(); 99 | 100 | return image; 101 | } 102 | 103 | -(void)setNavigationBarWithColor:(UIColor *)color 104 | { 105 | UIImage *image = [self imageWithColor:color]; 106 | 107 | [self setBackgroundImage:image forBarMetrics:UIBarMetricsDefault]; 108 | [self setBarStyle:UIBarStyleDefault]; 109 | [self setShadowImage:[UIImage new]]; 110 | [self setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]}]; 111 | [self setTintColor:[UIColor whiteColor]]; 112 | [self setTranslucent:YES]; 113 | 114 | } 115 | 116 | -(void)setNavigationBarWithColors:(NSArray *)colours 117 | { 118 | UIImage *image = [self imageWithGradients:colours]; 119 | 120 | [self setBackgroundImage:image forBarMetrics:UIBarMetricsDefault]; 121 | [self setBarStyle:UIBarStyleDefault]; 122 | [self setShadowImage:[UIImage new]]; 123 | [self setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]}]; 124 | [self setTintColor:[UIColor whiteColor]]; 125 | [self setTranslucent:YES]; 126 | } 127 | 128 | 129 | @end 130 | -------------------------------------------------------------------------------- /Demo/DSTranparentNavigationBar/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" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /Demo/DSTranparentNavigationBar/Images.xcassets/guayaquil.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "guayaquil.jpg" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Demo/DSTranparentNavigationBar/Images.xcassets/guayaquil.imageset/guayaquil.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diegoserranoa/DSTransparentNavigationBar/39ac42575fa1dc45764a866dc72129a8ce46fc06/Demo/DSTranparentNavigationBar/Images.xcassets/guayaquil.imageset/guayaquil.jpg -------------------------------------------------------------------------------- /Demo/DSTranparentNavigationBar/Images.xcassets/quito.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "quito.jpg" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Demo/DSTranparentNavigationBar/Images.xcassets/quito.imageset/quito.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diegoserranoa/DSTransparentNavigationBar/39ac42575fa1dc45764a866dc72129a8ce46fc06/Demo/DSTranparentNavigationBar/Images.xcassets/quito.imageset/quito.jpg -------------------------------------------------------------------------------- /Demo/DSTranparentNavigationBar/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.diegoserranoa.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /Demo/DSTranparentNavigationBar/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // DSTranparentNavigationBar 4 | // 5 | // Created by Diego Serrano on 10/13/14. 6 | // Copyright (c) 2014 Diego Serrano. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /Demo/DSTranparentNavigationBar/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // DSTranparentNavigationBar 4 | // 5 | // Created by Diego Serrano on 10/13/14. 6 | // Copyright (c) 2014 Diego Serrano. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @interface ViewController () 12 | 13 | @end 14 | 15 | @implementation ViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | // Do any additional setup after loading the view, typically from a nib. 20 | 21 | self.navigationItem.title = @"Transparent NavBar"; 22 | } 23 | 24 | - (void)didReceiveMemoryWarning { 25 | [super didReceiveMemoryWarning]; 26 | // Dispose of any resources that can be recreated. 27 | } 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Demo/DSTranparentNavigationBar/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // DSTranparentNavigationBar 4 | // 5 | // Created by Diego Serrano on 10/13/14. 6 | // Copyright (c) 2014 Diego Serrano. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Demo/DSTranparentNavigationBarTests/DSTranparentNavigationBarTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // DSTranparentNavigationBarTests.m 3 | // DSTranparentNavigationBarTests 4 | // 5 | // Created by Diego Serrano on 10/13/14. 6 | // Copyright (c) 2014 Diego Serrano. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface DSTranparentNavigationBarTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation DSTranparentNavigationBarTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Demo/DSTranparentNavigationBarTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.diegoserranoa.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Diego 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 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | DSTransparentNavigationBar 2 | ========================== 3 | 4 | UINavigationBar that allows to set a transparency colors. 5 | 6 | 7 | ![zero alpha](https://github.com/diegoserranoa/DSTransparentNavigationBar/blob/master/img/alpha0.png) 8 | 9 | ![0.5 alpha](https://github.com/diegoserranoa/DSTransparentNavigationBar/blob/master/img/alpha05.png) 10 | 11 | ![gradient alpha](https://github.com/diegoserranoa/DSTransparentNavigationBar/blob/master/img/gradientalpha.png) 12 | 13 | ## Usage 14 | 15 | Interface Builder 16 | 17 | Select the NavigationBar from the Navigation Controller in the Interface Builder. Then, in Utilities -> Identity Inspector select DSNavigationBar as the Class. 18 | 19 | ![IB screenshot](https://github.com/diegoserranoa/DSTransparentNavigationBar/blob/master/img/ib.png) 20 | 21 | Programatically 22 | 23 | In the AppDelegate import the header file and set the navigationBar class to DSNavigationBar 24 | 25 | ```objective-c 26 | #import "DSNavigationBar.h" 27 | 28 | UINavigationController *navigationController = [[UINavigationController alloc] initWithNavigationBarClass:[DSNavigationBar class] toolbarClass:nil]; 29 | 30 | // create a color and set it to the DSNavigationBar appearance 31 | UIColor * color = [UIColor colorWithRed:(190/255.0) green:(218/255.0) blue:(218/255) alpha:0.5f]; 32 | [[DSNavigationBar appearance] setNavigationBarWithColor:color]; 33 | 34 | // creating a fade out effect 35 | /* 36 | UIColor *topColor = [UIColor colorWithRed:(190/255.0) green:(218/255.0) blue:(218/255) alpha:1.0f]; 37 | UIColor *bottomColor = [UIColor colorWithRed:(190/255.0) green:(218/255.0) blue:(218/255) alpha:0]; 38 | [[DSNavigationBar appearance] setNavigationBarWithColors:@[topColor,bottomColor]]; 39 | */ 40 | 41 | ``` 42 | --- 43 | 44 | ## License 45 | Under the MIT license. More info on the LICENSE file. 46 | 47 | ## TODO 48 | - Swift implementation 49 | - iOS 7 support. 50 | -------------------------------------------------------------------------------- /img/alpha0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diegoserranoa/DSTransparentNavigationBar/39ac42575fa1dc45764a866dc72129a8ce46fc06/img/alpha0.png -------------------------------------------------------------------------------- /img/alpha05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diegoserranoa/DSTransparentNavigationBar/39ac42575fa1dc45764a866dc72129a8ce46fc06/img/alpha05.png -------------------------------------------------------------------------------- /img/gradientalpha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diegoserranoa/DSTransparentNavigationBar/39ac42575fa1dc45764a866dc72129a8ce46fc06/img/gradientalpha.png -------------------------------------------------------------------------------- /img/ib.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/diegoserranoa/DSTransparentNavigationBar/39ac42575fa1dc45764a866dc72129a8ce46fc06/img/ib.png --------------------------------------------------------------------------------