forked from freak4pc/SMTagField
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SMTag.m
68 lines (52 loc) · 1.85 KB
/
SMTag.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
//
// SMTag.m
//
// Created by Shai Mishali on 6/3/13.
// Copyright (c) 2013 Shai Mishali. All rights reserved.
//
#import "SMTag.h"
@implementation SMTag
@synthesize value;
@dynamic borderColor, font, textColor;
-(id)initWithTag:(NSString *)tag{
if(self = [super init]){
self.backgroundColor = [UIColor colorWithRed:0.7215686275 green:0.7490196078 blue:0.7882352941 alpha:1.0];
self.titleLabel.font = [UIFont systemFontOfSize: 11];
self.layer.cornerRadius = 5;
self.layer.masksToBounds= YES;
self.layer.borderColor = [UIColor colorWithRed:0.5333333333 green:0.6862745098 blue:0.8470588235 alpha:1.0].CGColor;
self.layer.borderWidth = 1;
self.showsTouchWhenHighlighted = YES;
value = tag;
[self setTitle:[NSString stringWithFormat:@" %@ ", tag] forState:UIControlStateNormal];
[self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[self sizeToFit];
CGRect selfFrame = self.frame;
selfFrame.size.height = 25;
self.frame = selfFrame;
}
return self;
}
-(void)setValue:(NSString *)aValue{
[self setTitle:[NSString stringWithFormat:@" %@ ", aValue] forState:UIControlStateNormal];
self.value = aValue;
}
-(UIColor *)borderColor{
return [UIColor colorWithCGColor: self.layer.borderColor];
}
-(void)setBorderColor:(UIColor *)borderColor{
self.layer.borderColor = borderColor.CGColor;
}
-(UIFont *)font{
return self.titleLabel.font;
}
-(void)setFont:(UIFont *)font{
self.titleLabel.font = font;
}
-(UIColor *)textColor{
return [self titleColorForState: UIControlStateNormal];
}
-(void)setTextColor:(UIColor *)textColor{
[self setTitleColor:textColor forState:UIControlStateNormal];
}
@end