-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathJDStatusBarStyle.m
executable file
·106 lines (92 loc) · 3.67 KB
/
JDStatusBarStyle.m
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
101
102
103
104
105
106
//
// JDStatusBarStyle.m
// JDStatusBarNotificationExample
//
// Created by Markus on 04.12.13.
// Copyright (c) 2013 Markus. All rights reserved.
//
#import "JDStatusBarStyle.h"
NSString *const JDStatusBarStyleError = @"JDStatusBarStyleError";
NSString *const JDStatusBarStyleWarning = @"JDStatusBarStyleWarning";
NSString *const JDStatusBarStyleSuccess = @"JDStatusBarStyleSuccess";
NSString *const JDStatusBarStyleMatrix = @"JDStatusBarStyleMatrix";
NSString *const JDStatusBarStyleDefault = @"JDStatusBarStyleDefault";
NSString *const JDStatusBarStyleDark = @"JDStatusBarStyleDark";
@implementation JDStatusBarStyle
- (instancetype)copyWithZone:(NSZone*)zone;
{
JDStatusBarStyle *style = [[[self class] allocWithZone:zone] init];
style.barColor = self.barColor;
style.textColor = self.textColor;
style.textShadow = self.textShadow;
style.font = self.font;
style.textVerticalPositionAdjustment = self.textVerticalPositionAdjustment;
style.animationType = self.animationType;
style.progressBarColor = self.progressBarColor;
style.progressBarHeight = self.progressBarHeight;
style.progressBarPosition = self.progressBarPosition;
return style;
}
+ (NSArray*)allDefaultStyleIdentifier;
{
return @[JDStatusBarStyleError, JDStatusBarStyleWarning,
JDStatusBarStyleSuccess, JDStatusBarStyleMatrix,
JDStatusBarStyleDark];
}
+ (JDStatusBarStyle*)defaultStyleWithName:(NSString*)styleName;
{
// setup default style
JDStatusBarStyle *style = [[JDStatusBarStyle alloc] init];
style.barColor = [UIColor whiteColor];
style.progressBarColor = [UIColor greenColor];
style.progressBarHeight = 1.0;
style.progressBarPosition = JDStatusBarProgressBarPositionBottom;
style.textColor = [UIColor grayColor];
style.font = [UIFont systemFontOfSize:12.0];
style.animationType = JDStatusBarAnimationTypeMove;
// JDStatusBarStyleDefault
if ([styleName isEqualToString:JDStatusBarStyleDefault]) {
return style;
}
// JDStatusBarStyleError
else if ([styleName isEqualToString:JDStatusBarStyleError]) {
style.barColor = [UIColor colorWithRed:255.0/255.0 green:88.0/255.0 blue:71.0/255.0 alpha:1.000];
style.textColor = [UIColor whiteColor];
style.progressBarColor = [UIColor redColor];
style.progressBarHeight = 2.0;
return style;
}
// JDStatusBarStyleWarning
else if ([styleName isEqualToString:JDStatusBarStyleWarning]) {
style.barColor = [UIColor colorWithRed:0.900 green:0.734 blue:0.034 alpha:1.000];
style.textColor = [UIColor darkGrayColor];
style.progressBarColor = style.textColor;
return style;
}
// JDStatusBarStyleSuccess
else if ([styleName isEqualToString:JDStatusBarStyleSuccess]) {
style.barColor = [UIColor colorWithRed:59.0/255.0 green:189.0/255.0 blue:121.0/255.0 alpha:1.000];
style.textColor = [UIColor whiteColor];
style.progressBarColor = [UIColor colorWithRed:0.106 green:0.594 blue:0.319 alpha:1.000];
style.progressBarHeight = 1.0+1.0/[[UIScreen mainScreen] scale];
return style;
}
// JDStatusBarStyleDark
else if ([styleName isEqualToString:JDStatusBarStyleDark]) {
style.barColor = [UIColor colorWithRed:0.050 green:0.078 blue:0.120 alpha:1.000];
style.textColor = [UIColor colorWithWhite:0.95 alpha:1.0];
style.progressBarHeight = 1.0+1.0/[[UIScreen mainScreen] scale];
return style;
}
// JDStatusBarStyleMatrix
else if ([styleName isEqualToString:JDStatusBarStyleMatrix]) {
style.barColor = [UIColor blackColor];
style.textColor = [UIColor greenColor];
style.font = [UIFont fontWithName:@"Courier-Bold" size:14.0];
style.progressBarColor = [UIColor greenColor];
style.progressBarHeight = 2.0;
return style;
}
return nil;
}
@end