-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTXTStyleCell.m
43 lines (32 loc) · 1.22 KB
/
TXTStyleCell.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
#import "TXTStyleCell.h"
#import "TXTStyleManager.h"
@implementation TXTStyleCell
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
_label = [[UILabel alloc] init];
[_label setTextColor:[UIColor labelColor]];
[_label setTextAlignment:NSTextAlignmentCenter];
[_label setFont:[UIFont systemFontOfSize:16]];
[self.contentView addSubview:_label];
[_label setTranslatesAutoresizingMaskIntoConstraints: NO];
[_label.centerXAnchor constraintEqualToAnchor:self.contentView.centerXAnchor].active = YES;
[_label.centerYAnchor constraintEqualToAnchor:self.contentView.centerYAnchor].active = YES;
}
return self;
}
- (void)updateConfigurationUsingState:(UICellConfigurationState *)state {
[super updateConfigurationUsingState:state];
if (state.isSelected) {
[[TXTStyleManager sharedManager] selectStyle:_label.text];
[UIView animateWithDuration:0.25
animations:^{
[self setBackgroundColor:[UIColor colorWithRed:1.00 green:0.18 blue:0.33 alpha:1.0f]];
}
];
}
else {
[self setBackgroundColor:[UIColor clearColor]];
}
}
@end