Skip to content

Commit f9107d6

Browse files
author
jrapoport
committed
Merge remote-tracking branch 'appwilldev/master'
2 parents f41b635 + 800cf6e commit f9107d6

File tree

3 files changed

+28
-13
lines changed

3 files changed

+28
-13
lines changed

AWLThemeManager.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
1616
#
1717

1818
s.name = "AWLThemeManager"
19-
s.version = "1.0.2"
19+
s.version = "1.0.3"
2020
s.summary = "AWLThemeManager is a lightweight theme manager for iOS."
2121
s.homepage = "https://github.com/appwilldev/AWLThemeManager"
2222
# s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif"

AWLThemeManager/AWLThemeManager.m

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,12 @@ - (UIColor *)colorForKey:(NSString *)key forTheme:(NSString *)themeName
8888
NSString *colorValue = [self objectForKey:key forTheme:themeName];
8989
UIColor *color = [self colorFromString:colorValue];
9090
if (color == nil && [self isValidString:colorValue]) {
91+
NSArray* referenceColor = [colorValue componentsSeparatedByString: @":"];
92+
colorValue = referenceColor.firstObject;
9193
color = [self colorForKey:colorValue forTheme:themeName];
94+
if (referenceColor.count > 1) {
95+
color = [color colorWithAlphaComponent: [referenceColor[1] doubleValue]];
96+
}
9297
}
9398

9499
return color;
@@ -98,11 +103,15 @@ - (UIColor*)colorFromString:(NSString*)colorValue
98103
{
99104
if ([self isValidString:colorValue]) {
100105
NSArray* array = [colorValue componentsSeparatedByString:@","];
101-
if (array && [array count] == 4) {
102-
return [UIColor colorWithRed:[array[0] floatValue]/255
103-
green:[array[1] floatValue]/255
104-
blue:[array[2] floatValue]/255
105-
alpha:[array[3] floatValue]];
106+
if (array && [array count] == 2) {
107+
return [UIColor colorWithWhite:[array[0] doubleValue]
108+
alpha:[array[1] doubleValue]];
109+
}
110+
else if (array && [array count] == 4) {
111+
return [UIColor colorWithRed:[array[0] doubleValue]/255.0
112+
green:[array[1] doubleValue]/255.0
113+
blue:[array[2] doubleValue]/255.0
114+
alpha:[array[3] doubleValue]];
106115
}
107116
}
108117

@@ -173,7 +182,7 @@ - (UIFont*)fontFromString:(NSString*)fontValue
173182
NSArray *array = [fontValue componentsSeparatedByString:@","];
174183
if (array && array.count == 2) {
175184
NSString *fontName = array[0];
176-
CGFloat fontSize = [array[1] floatValue];
185+
CGFloat fontSize = [array[1] doubleValue];
177186
if ([self isValidString:fontName]) {
178187
if ([fontName isEqualToString:@"bold"]) {
179188
font = [UIFont boldSystemFontOfSize:fontSize];

README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,20 @@ The format of color is :
6363

6464
It will return the color use follow method:
6565

66-
[UIColor colorWithRed:[array[0] floatValue]/255
67-
green:[array[1] floatValue]/255
68-
blue:[array[2] floatValue]/255
69-
alpha:[array[3] floatValue]];
66+
[UIColor colorWithRed:[array[0] doubleValue]/255
67+
green:[array[1] doubleValue]/255
68+
blue:[array[2] doubleValue]/255
69+
alpha:[array[3] doubleValue]];
7070

7171
Make sure you set the right value to the color.
7272

73-
**Support reference** If you want to set the same value to different color key, you can set the key of one color to another color, then AWLThemeManager will find the actual value of the color.
73+
**Support white colorspace format**. Colors can now be specified in white colorspace (e.g. 0.4,1).
74+
75+
**Support reference**. If you want to set the same value to different color key, you can set the key of one color to another color, then AWLThemeManager will find the actual value of the color.
76+
77+
**Modify alpha by reference**. If you reference a color, e.g. “COLOR1” = “255,0,0,1”, “COLOR2” =
78+
“COLOR1” you can now append “:[alpha]” to the reference to modify it’s
79+
alpha, e.g. “COLOR2” = “COLOR1:0.2” will equate to “255,0,0,0.2”.
7480

7581
#### Define Font
7682
The format of font is :
@@ -88,7 +94,7 @@ If you want to use system font, you should ignore the first value, like this:
8894
bold,14 //boldSystemFontOfSize
8995
italic,14 //italicSystemFontOfSize
9096

91-
**Support reference** Same with the color
97+
**Support reference** Same with the color.
9298

9399
You can add whatever you want to the defaults.plist. Just use `objectForKey:` to get the value.
94100

0 commit comments

Comments
 (0)