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
69
70
71
72
73
74
75
76
77
78
//
// IBTTableViewCell.m
// IBTTableViewKit
//
// Created by Xummer on 15/1/5.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "IBTTableViewCell.h"
@interface IBTTableViewCell ()
@end
@implementation IBTTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (!self) {
return nil;
}
return self;
}
- (void)awakeFromNib {
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
#pragma mark - Setter
- (void)setAccessoryType:(UITableViewCellAccessoryType)accessoryType {
[super setAccessoryType:accessoryType];
self.accessoryView = nil;
switch (accessoryType) {
case UITableViewCellAccessoryDisclosureIndicator:
{
__block UIButton *arrowBtn = nil;
[self.subviews enumerateObjectsWithOptions:NSEnumerationReverse
usingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
if ([obj isKindOfClass:[UIButton class]]) {
arrowBtn = obj;
*stop = YES;
}
}];
[arrowBtn setImage:[UIImage imageNamed:@"CellCustomArrow"]
forState:UIControlStateNormal];
}
break;
default:
break;
}
}
#pragma mark - Private
- (void)addCustomArrow {
UIImage *image = [UIImage imageNamed:@"CellCustomArrow"];
UIButton *customArrow = [UIButton buttonWithType:UIButtonTypeCustom];
[customArrow setImage:image forState:UIControlStateNormal];
customArrow.frame = (CGRect){
.origin.x = CGRectGetWidth(self.bounds) - 11 - image.size.width,
.origin.y = (CGRectGetHeight(self.bounds) - image.size.height) * .5f,
.size = image.size
};
[self addSubview:customArrow];
self.accessoryView = customArrow;
}
@end