-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmaterialNavBar.m
More file actions
57 lines (42 loc) · 1.53 KB
/
materialNavBar.m
File metadata and controls
57 lines (42 loc) · 1.53 KB
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
//
// materialNavBar.m
// Material NavBar and StatusBar
//
// Created by Daniel Katz on 5/1/16.
// Copyright © 2016 Stratton Design. All rights reserved.
//
#import "materialNavBar.h"
@implementation materialNavBar
-(void)setMaterialColor:(UIColor *)color{
self.translucent = NO;
[self setBarTintColor:color];
[self calculateDarkColorfromColor:color];
self.layer.shadowOffset = CGSizeMake(0, 1);
self.layer.shadowRadius = 3;
self.layer.shadowOpacity = .6f;
[self setShadowImage:[[UIImage alloc] init]];
[self setBackgroundImage:[[UIImage alloc]init] forBarMetrics:UIBarMetricsDefault];
}
-(void)calculateDarkColorfromColor : (UIColor *)color{
CGFloat red, green, blue, alpha;
[color getRed: &red
green: &green
blue: &blue
alpha: &alpha];
NSLog(@"red = %f. Green = %f. Blue = %f. Alpha = %f",
red,
green,
blue,
alpha);
color = [UIColor colorWithRed:red*.7 green:green*.7 blue:blue*.7 alpha:alpha];
[self setStatusBarBackgroundColor:color];
}
- (void)setStatusBarBackgroundColor:(UIColor *)color {
UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
statusBar.backgroundColor = color;
}
}
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
@end