Skip to content

Commit 82c738c

Browse files
committed
Merge branch 'master' of github.com:Grouper/FlatUIKit
2 parents e2316a5 + 44879d1 commit 82c738c

File tree

3 files changed

+72
-51
lines changed

3 files changed

+72
-51
lines changed

Classes/ios/UIBarButtonItem+FlatUI.m

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -14,76 +14,76 @@ @implementation UIBarButtonItem (FlatUI)
1414
- (void) configureFlatButtonWithColor:(UIColor *)color
1515
highlightedColor:(UIColor *)highlightedColor
1616
cornerRadius:(CGFloat) cornerRadius {
17-
18-
[UIBarButtonItem configureItemOrProxy:self forFlatButtonWithColor:color highlightedColor:color cornerRadius:cornerRadius];
19-
17+
18+
[UIBarButtonItem configureItemOrProxy:self forFlatButtonWithColor:color highlightedColor:highlightedColor cornerRadius:cornerRadius];
19+
2020
}
2121

2222
+ (void) configureFlatButtonsWithColor:(UIColor *) color
2323
highlightedColor:(UIColor *)highlightedColor
2424
cornerRadius:(CGFloat) cornerRadius {
25-
26-
[self configureFlatButtonsWithColor:color highlightedColor:highlightedColor cornerRadius:cornerRadius whenContainedIn:[UINavigationBar class], [UINavigationController class], nil];
25+
26+
[self configureFlatButtonsWithColor:color highlightedColor:highlightedColor cornerRadius:cornerRadius whenContainedIn:[UINavigationBar class], [UINavigationController class], nil];
2727
}
2828

2929
+ (void) configureFlatButtonsWithColor:(UIColor *) color
3030
highlightedColor:(UIColor *)highlightedColor
3131
cornerRadius:(CGFloat) cornerRadius
3232
whenContainedIn:(Class <UIAppearanceContainer>)containerClass, ... {
33-
va_list vl;
34-
va_start(vl, containerClass);
35-
id appearance = [UIBarButtonItem appearanceWhenContainedIn:containerClass, nil];
36-
va_end(vl);
37-
[UIBarButtonItem configureItemOrProxy:appearance forFlatButtonWithColor:color highlightedColor:color cornerRadius:cornerRadius];
33+
va_list vl;
34+
va_start(vl, containerClass);
35+
id appearance = [UIBarButtonItem appearanceWhenContainedIn:containerClass, nil];
36+
va_end(vl);
37+
[UIBarButtonItem configureItemOrProxy:appearance forFlatButtonWithColor:color highlightedColor:highlightedColor cornerRadius:cornerRadius];
3838
}
3939

4040
- (void) removeTitleShadow {
41-
NSMutableDictionary *titleTextAttributes = [[self titleTextAttributesForState:UIControlStateNormal] mutableCopy];
42-
if (!titleTextAttributes) {
43-
titleTextAttributes = [NSMutableDictionary dictionary];
44-
}
45-
[titleTextAttributes setValue:[NSValue valueWithUIOffset:UIOffsetMake(0, 0)] forKey:UITextAttributeTextShadowOffset];
46-
[self setTitleTextAttributes:titleTextAttributes forState:UIControlStateNormal];
41+
NSMutableDictionary *titleTextAttributes = [[self titleTextAttributesForState:UIControlStateNormal] mutableCopy];
42+
if (!titleTextAttributes) {
43+
titleTextAttributes = [NSMutableDictionary dictionary];
44+
}
45+
[titleTextAttributes setValue:[NSValue valueWithUIOffset:UIOffsetMake(0, 0)] forKey:UITextAttributeTextShadowOffset];
46+
[self setTitleTextAttributes:titleTextAttributes forState:UIControlStateNormal];
4747
}
4848

4949
//helper method, basically a wrapper to allow creating a custom UIAppearance method that doesn't conform to the usual naming style
5050
+ (void) configureItemOrProxy:(id)appearance
5151
forFlatButtonWithColor:(UIColor *)color
5252
highlightedColor:(UIColor *)highlightedColor
5353
cornerRadius:(CGFloat) cornerRadius {
54-
UIImage *backButtonPortraitImage = [UIImage backButtonImageWithColor:color
55-
barMetrics:UIBarMetricsDefault
56-
cornerRadius:cornerRadius];
57-
UIImage *highlightedBackButtonPortraitImage = [UIImage backButtonImageWithColor:highlightedColor
58-
barMetrics:UIBarMetricsDefault
59-
cornerRadius:cornerRadius];
60-
UIImage *backButtonLandscapeImage = [UIImage backButtonImageWithColor:color
61-
barMetrics:UIBarMetricsLandscapePhone
62-
cornerRadius:2];
63-
UIImage *highlightedBackButtonLandscapeImage = [UIImage backButtonImageWithColor:highlightedColor
64-
barMetrics:UIBarMetricsLandscapePhone
65-
cornerRadius:2];
66-
67-
[appearance setBackButtonBackgroundImage:backButtonPortraitImage
68-
forState:UIControlStateNormal
69-
barMetrics:UIBarMetricsDefault];
70-
[appearance setBackButtonBackgroundImage:backButtonLandscapeImage
71-
forState:UIControlStateNormal
72-
barMetrics:UIBarMetricsLandscapePhone];
73-
[appearance setBackButtonBackgroundImage:highlightedBackButtonPortraitImage
74-
forState:UIControlStateHighlighted
75-
barMetrics:UIBarMetricsDefault];
76-
[appearance setBackButtonBackgroundImage:highlightedBackButtonLandscapeImage
77-
forState:UIControlStateHighlighted
78-
barMetrics:UIBarMetricsLandscapePhone];
79-
80-
[appearance setBackButtonTitlePositionAdjustment:UIOffsetMake(1.0f, 1.0f) forBarMetrics:UIBarMetricsDefault];
81-
[appearance setBackButtonTitlePositionAdjustment:UIOffsetMake(1.0f, 1.0f) forBarMetrics:UIBarMetricsLandscapePhone];
82-
83-
UIImage *buttonImage = [UIImage imageWithColor:color cornerRadius:cornerRadius];
84-
[appearance setBackgroundImage:buttonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
85-
54+
UIImage *backButtonPortraitImage = [UIImage backButtonImageWithColor:color
55+
barMetrics:UIBarMetricsDefault
56+
cornerRadius:cornerRadius];
57+
UIImage *highlightedBackButtonPortraitImage = [UIImage backButtonImageWithColor:highlightedColor
58+
barMetrics:UIBarMetricsDefault
59+
cornerRadius:cornerRadius];
60+
UIImage *backButtonLandscapeImage = [UIImage backButtonImageWithColor:color
61+
barMetrics:UIBarMetricsLandscapePhone
62+
cornerRadius:2];
63+
UIImage *highlightedBackButtonLandscapeImage = [UIImage backButtonImageWithColor:highlightedColor
64+
barMetrics:UIBarMetricsLandscapePhone
65+
cornerRadius:2];
66+
67+
[appearance setBackButtonBackgroundImage:backButtonPortraitImage
68+
forState:UIControlStateNormal
69+
barMetrics:UIBarMetricsDefault];
70+
[appearance setBackButtonBackgroundImage:backButtonLandscapeImage
71+
forState:UIControlStateNormal
72+
barMetrics:UIBarMetricsLandscapePhone];
73+
[appearance setBackButtonBackgroundImage:highlightedBackButtonPortraitImage
74+
forState:UIControlStateHighlighted
75+
barMetrics:UIBarMetricsDefault];
76+
[appearance setBackButtonBackgroundImage:highlightedBackButtonLandscapeImage
77+
forState:UIControlStateHighlighted
78+
barMetrics:UIBarMetricsLandscapePhone];
79+
80+
[appearance setBackButtonTitlePositionAdjustment:UIOffsetMake(1.0f, 1.0f) forBarMetrics:UIBarMetricsDefault];
81+
[appearance setBackButtonTitlePositionAdjustment:UIOffsetMake(1.0f, 1.0f) forBarMetrics:UIBarMetricsLandscapePhone];
82+
83+
UIImage *buttonImageNormal = [UIImage imageWithColor:color cornerRadius:cornerRadius];
84+
UIImage *buttonImageHightlighted = [UIImage imageWithColor:highlightedColor cornerRadius:cornerRadius];
85+
[appearance setBackgroundImage:buttonImageNormal forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
86+
[appearance setBackgroundImage:buttonImageHightlighted forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
8687
}
8788

88-
8989
@end

Classes/ios/UISlider+FlatUI.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,9 @@
1414
progressColor:(UIColor *)progressColor
1515
thumbColor:(UIColor *)thumbColor;
1616

17+
- (void) configureFlatSliderWithTrackColor:(UIColor *)trackColor
18+
progressColor:(UIColor *)progressColor
19+
thumbColorNormal:(UIColor *)thumbColorNormal
20+
thumbColorHighlighted:(UIColor *)highlightedThumbColor;
21+
1722
@end

Classes/ios/UISlider+FlatUI.m

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,31 @@ - (void) configureFlatSliderWithTrackColor:(UIColor *)trackColor
1515
progressColor:(UIColor *)progressColor
1616
thumbColor:(UIColor *)thumbColor {
1717

18+
[self configureFlatSliderWithTrackColor:trackColor
19+
progressColor:progressColor
20+
thumbColorNormal:thumbColor
21+
thumbColorHighlighted:thumbColor];
22+
}
23+
24+
- (void) configureFlatSliderWithTrackColor:(UIColor *)trackColor
25+
progressColor:(UIColor *)progressColor
26+
thumbColorNormal:(UIColor *)normalThumbColor
27+
thumbColorHighlighted:(UIColor *)highlightedThumbColor
28+
{
29+
1830
UIImage *progressImage = [[UIImage imageWithColor:progressColor cornerRadius:5.0]
1931
imageWithMinimumSize:CGSizeMake(10, 10)];
2032
UIImage *trackImage = [[UIImage imageWithColor:trackColor cornerRadius:5.0]
2133
imageWithMinimumSize:CGSizeMake(10, 10)];
22-
34+
2335
[self setMinimumTrackImage:progressImage forState:UIControlStateNormal];
2436
[self setMaximumTrackImage:trackImage forState:UIControlStateNormal];
25-
UIImage *normalSliderImage = [UIImage circularImageWithColor:thumbColor size:CGSizeMake(24, 24)];
37+
38+
UIImage *normalSliderImage = [UIImage circularImageWithColor:normalThumbColor size:CGSizeMake(24, 24)];
2639
[self setThumbImage:normalSliderImage forState:UIControlStateNormal];
40+
41+
UIImage *highlighedSliderImage = [UIImage circularImageWithColor:highlightedThumbColor size:CGSizeMake(24, 24)];
42+
[self setThumbImage:highlighedSliderImage forState:UIControlStateHighlighted];
2743
}
2844

2945
@end

0 commit comments

Comments
 (0)