|
//////////////////////////// |
|
// CRNavigationBar.m |
|
//////////////////////////// |
|
|
|
#import "CRNavigationBar.h" |
|
|
|
@interface CRNavigationBar () |
|
@property (nonatomic, strong) CALayer *colorLayer; |
|
@end |
|
|
|
@implementation CRNavigationBar |
|
|
|
static CGFloat const kDefaultColorLayerOpacity = 0.5f; |
|
static CGFloat const kSpaceToCoverStatusBars = 20.0f; |
|
|
|
- (void)setBarTintColor:(UIColor *)barTintColor { |
|
[super setBarTintColor:barTintColor]; |
|
if (self.colorLayer == nil) { |
|
self.colorLayer = [CALayer layer]; |
|
self.colorLayer.opacity = kDefaultColorLayerOpacity; |
|
[self.layer addSublayer:self.colorLayer]; |
|
} |
|
self.colorLayer.backgroundColor = barTintColor.CGColor; |
|
} |
|
|
|
- (void)layoutSubviews { |
|
[super layoutSubviews]; |
|
if (self.colorLayer != nil) { |
|
self.colorLayer.frame = CGRectMake(0, 0 - kSpaceToCoverStatusBars, CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds) + kSpaceToCoverStatusBars); |
|
|
|
[self.layer insertSublayer:self.colorLayer atIndex:1]; |
|
} |
|
} |
|
|
|
@end |
|
|
|
//////////////////////////// |
|
// CRNavigationController.m |
|
//////////////////////////// |
|
|
|
#import "CRNavigationController.h" |
|
#import "CRNavigationBar.h" |
|
|
|
@interface CRNavigationController () |
|
|
|
@end |
|
|
|
@implementation CRNavigationController |
|
|
|
- (id)init { |
|
self = [super initWithNavigationBarClass:[CRNavigationBar class] toolbarClass:nil]; |
|
if(self) { |
|
// Custom initialization here, if needed. |
|
} |
|
return self; |
|
} |
|
|
|
- (id)initWithRootViewController:(UIViewController *)rootViewController { |
|
self = [super initWithNavigationBarClass:[CRNavigationBar class] toolbarClass:nil]; |
|
if(self) { |
|
self.viewControllers = @[rootViewController]; |
|
} |
|
|
|
return self; |
|
} |
|
|
|
@end |
Still using this?