-
Notifications
You must be signed in to change notification settings - Fork 0
/
UIStepper+FlatUI.m
executable file
·47 lines (41 loc) · 2.15 KB
/
UIStepper+FlatUI.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
//
// UIStepper+FlatUI.m
// FlatUI
//
// Created by Jack Flintermann on 5/3/13.
// Copyright (c) 2013 Jack Flintermann. All rights reserved.
//
#import "UIStepper+FlatUI.h"
#import "UIImage+FlatUI.h"
#import <CoreText/CoreText.h>
@implementation UIStepper (FlatUI)
- (void) configureFlatStepperWithColor:(UIColor *)color
highlightedColor:(UIColor *)highlightedColor
disabledColor:(UIColor *)disabledColor
iconColor:(UIColor *)iconColor {
// iOS 6 compat check
if ([self respondsToSelector:@selector(setBackgroundImage:forState:)]) {
UIImage *normalImage = [UIImage imageWithColor:color cornerRadius:2.0];
UIImage *highlightedImage = [UIImage imageWithColor:highlightedColor cornerRadius:2.0];
UIImage *disabledImage = [UIImage imageWithColor:disabledColor cornerRadius:2.0];
[self setBackgroundImage:normalImage forState:UIControlStateNormal];
[self setBackgroundImage:highlightedImage forState:UIControlStateHighlighted];
[self setBackgroundImage:disabledImage forState:UIControlStateDisabled];
[self setDividerImage:[UIImage imageWithColor:highlightedColor cornerRadius:0]
forLeftSegmentState:UIControlStateNormal
rightSegmentState:UIControlStateNormal];
[self setDividerImage:[UIImage imageWithColor:highlightedColor cornerRadius:0]
forLeftSegmentState:UIControlStateHighlighted
rightSegmentState:UIControlStateNormal];
[self setDividerImage:[UIImage imageWithColor:highlightedColor cornerRadius:0]
forLeftSegmentState:UIControlStateNormal
rightSegmentState:UIControlStateHighlighted];
UIImage *plusImage = [UIImage stepperPlusImageWithColor:iconColor];
UIImage *minusImage = [UIImage stepperMinusImageWithColor:iconColor];
[self setIncrementImage:plusImage forState:UIControlStateNormal];
[self setIncrementImage:plusImage forState:UIControlStateDisabled];
[self setDecrementImage:minusImage forState:UIControlStateNormal];
[self setDecrementImage:minusImage forState:UIControlStateDisabled];
}
}
@end