-
Notifications
You must be signed in to change notification settings - Fork 182
Expand file tree
/
Copy pathPKBorderedButton.m
More file actions
49 lines (39 loc) · 1.32 KB
/
PKBorderedButton.m
File metadata and controls
49 lines (39 loc) · 1.32 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
//
// PKBorderedButton.m
// Pods
//
// Created by Holden, Ryan on 2/7/16.
//
//
#import "PKBorderedButton.h"
#import "UIImage+PKDownloadButton.h"
@implementation PKBorderedButton
- (void)setCornerRadius:(CGFloat)cornerRadius {
_cornerRadius = cornerRadius;
[self updateBackgroundImage];
}
- (void)setLineWidth:(CGFloat)lineWidth {
_lineWidth = lineWidth;
[self updateBackgroundImage];
}
- (void)configureDefaultAppearance {
[self setCornerRadius:4];
[self setLineWidth:1];
}
- (void)updateBackgroundImage {
[self setBackgroundImage:[UIImage borderedImageWithFill:nil radius:self.cornerRadius lineColor:self.tintColor lineWidth:self.lineWidth]
forState:UIControlStateNormal];
[self setBackgroundImage:[UIImage borderedImageWithFill:self.tintColor radius:self.cornerRadius lineColor:self.tintColor lineWidth:self.lineWidth]
forState:UIControlStateHighlighted];
}
- (void)tintColorDidChange {
[super tintColorDidChange];
[self updateBackgroundImage];
}
- (void)cleanDefaultAppearance {
[self setBackgroundImage:nil forState:UIControlStateNormal];
[self setBackgroundImage:nil forState:UIControlStateHighlighted];
[self setAttributedTitle:nil forState:UIControlStateNormal];
[self setAttributedTitle:nil forState:UIControlStateHighlighted];
}
@end