ApplyForShootCell.m
6.25 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
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
//
// ApplyForShootCell.m
// com.cnlive.pro.CNLiveNetAdd
//
// Created by cnliveJunBo on 2018/4/12.
// Copyright © 2018年 cnlive. All rights reserved.
//
#import "ApplyForShootCell.h"
#import <Masonry/Masonry.h>
#import "CNLiveBaseKit.h"
#import <QMUIKit/QMUIKit.h>
#import "CNLiveIDCardAuthGetImage.h"
@interface ApplyForShootCell ()
@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UILabel *subTitleLab;
@property (nonatomic, strong) UIButton *shootBtn;
@property (nonatomic, strong) UIView *lineV;
@end
@implementation ApplyForShootCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
[self setupUI];
}
return self;
}
- (void)setModel:(AgreementModel *)model {
_titleLab.text = model.shootTitle;
_imgV.image = [CNLiveIDCardAuthGetImage cnLiveIDCardAuth_getImageName:model.shootImage bundle:@"CNBPersonCardInfo.bundle/CNBPersonCardInfo" targetClass:[self class]];
if (model.isFront) {
self.lineV.hidden = NO;
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"请拍摄本人身份证正面 注意避免证件反光"];
NSRange range1 = [[str string] rangeOfString:@"请拍摄本人身份证"];
[str addAttribute:NSForegroundColorAttributeName value:RGBA(156, 156, 156, 1) range:range1];
NSRange range2 = [[str string] rangeOfString:@"正面"];
[str addAttribute:NSForegroundColorAttributeName value:RGBA(255, 59, 48, 1) range:range2];
NSRange range3 = [[str string] rangeOfString:@" 注意避免证件反光"];
[str addAttribute:NSForegroundColorAttributeName value:RGBA(156, 156, 156, 1) range:range3];
_subTitleLab.attributedText = str;
} else {
self.lineV.hidden = YES;
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"请拍摄本人身份证反面 注意避免证件反光"];
NSRange range1 = [[str string] rangeOfString:@"请拍摄本人身份证"];
[str addAttribute:NSForegroundColorAttributeName value:RGBA(156, 156, 156, 1) range:range1];
NSRange range2 = [[str string] rangeOfString:@"反面"];
[str addAttribute:NSForegroundColorAttributeName value:RGBA(255, 59, 48, 1) range:range2];
NSRange range3 = [[str string] rangeOfString:@" 注意避免证件反光"];
[str addAttribute:NSForegroundColorAttributeName value:RGBA(156, 156, 156, 1) range:range3];
_subTitleLab.attributedText = str;
}
}
- (void)setupUI {
[self.contentView addSubview:self.lineV];
[self.contentView addSubview:self.titleLab];
[self.contentView addSubview:self.subTitleLab];
[self.contentView addSubview:self.imgV];
// [self.imgV addSubview:self.shootBtn];
}
- (void)layoutSubviews {
[super layoutSubviews];
[self.lineV mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.top.right.equalTo(self.contentView);
make.height.mas_equalTo(1);
}];
[self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView).offset(69);
make.top.equalTo(_lineV.mas_bottom).offset(22);
make.width.mas_equalTo(64);
make.height.mas_equalTo(16);
}];
[self.subTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.contentView);
make.top.equalTo(self.titleLab.mas_bottom).offset(15);
make.width.mas_equalTo(245);
make.height.mas_equalTo(15);
}];
CGFloat width = KScreenWidth - 88;
CGFloat height = width*157.0/287.0;
[self.imgV mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.subTitleLab.mas_bottom).offset(10);
make.left.equalTo(self).offset(44);
make.right.equalTo(self).offset(-44);
make.height.mas_equalTo(height);
}];
// [self.shootBtn mas_makeConstraints:^(MASConstraintMaker *make) {
// make.center.equalTo(self.imgV);
// make.width.height.mas_equalTo(60);
// }];
}
- (void)shootPhotoAction:(UIButton *)sender{
if (self.clickShootBtnBlock) {
self.clickShootBtnBlock();
}
}
- (void)shootPhoto:(UITapGestureRecognizer *)tap {
if (self.clickShootBtnBlock) {
self.clickShootBtnBlock();
}
}
#pragma mark - SubViews
- (UILabel *)titleLab {
if (!_titleLab) {
_titleLab = [[UILabel alloc] init];
_titleLab.textColor = RGB(26, 26, 26);
_titleLab.font = [UIFont systemFontOfSize:16];
}
return _titleLab;
}
- (UILabel *)subTitleLab {
if (!_subTitleLab) {
_subTitleLab = [[UILabel alloc] init];
_subTitleLab.textColor = RGB(156, 156, 156);
_subTitleLab.font = [UIFont systemFontOfSize:12];
}
return _subTitleLab;
}
- (UIImageView *)imgV {
if (!_imgV) {
_imgV = [[UIImageView alloc] init];
_imgV.contentMode = UIViewContentModeScaleToFill;
_imgV.userInteractionEnabled = YES;
// _imgV.layer.borderWidth = 1.0f;
// _imgV.layer.borderColor = RGB(232, 232, 232).CGColor;
// _imgV.layer.cornerRadius = 6.0f;
// _imgV.layer.masksToBounds = YES;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(shootPhoto:)];
[_imgV addGestureRecognizer:tap];
}
return _imgV;
}
- (UIButton *)shootBtn {
if (!_shootBtn) {
_shootBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_shootBtn setImage:[CNLiveIDCardAuthGetImage cnLiveIDCardAuth_getImageName:@"dl_xiangji" bundle:@"CNBPersonCardInfo.bundle/CNLiveBPersonalVerificationModule" targetClass:[self class]] forState:UIControlStateNormal];
[_shootBtn addTarget:self action:@selector(shootPhotoAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _shootBtn;
}
- (UIView *)lineV {
if (!_lineV) {
_lineV = [[UIView alloc] init];
_lineV.backgroundColor = RGB(238, 238, 238);
}
return _lineV;
}
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end