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
//
//  HDLFVNormalCellView.m
//  Ezviz
//
//  Created by 陈启扬 on 2022/4/25.
//  Copyright © 2022 hdl. All rights reserved.
//
 
#import "HDLEZNormalCellView.h"
@interface HDLEZNormalCellView ()
@property (nonatomic, strong)UIImageView *nextImgV;//箭头图标
 
@end
@implementation HDLEZNormalCellView
 
-(instancetype)init{
    self = [super init];
    if (self) {
        [self initUI];
    }
    
    return  self;
}
 
-(void)initUI{
    self.backgroundColor=HDLEZ_COLOR_VIEW_FOREGROUND;
    
    //标题lable
    _titleL=[[UILabel alloc] init];
    [self addSubview:_titleL];
    [_titleL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self);
        make.left.equalTo(self).offset(16);
        make.width.mas_equalTo(0);
    }];
    _titleL.adjustsFontSizeToFitWidth=YES;
    _titleL.textColor=HDLEZ_COLOR_TEXT_TITLE_GRAY;
    _titleL.font=HDLEZ_Get_FontRegularWithSize(HDLEZ_FontSize_14);
 
    //右箭头
    _nextImgV=[[UIImageView alloc] init];
    [self addSubview:_nextImgV];
    [_nextImgV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-20);
        make.centerY.equalTo(self.mas_centerY);
        make.width.height.mas_equalTo(16);
    }];
    _nextImgV.image=[UIImage imageNamed:@"hdl_ez_list_next"];
 
    //内容lable
    _contentL=[[UILabel alloc] init];
    [self addSubview:_contentL];
    [_contentL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self);
        make.left.equalTo(_titleL.mas_right).offset(5);
        make.right.equalTo(_nextImgV.mas_left).offset(-5);
    }];
    _contentL.adjustsFontSizeToFitWidth=YES;
    _contentL.numberOfLines=2;
    _contentL.textAlignment=NSTextAlignmentRight;
    _contentL.textColor=HDLEZ_COLOR_TEXT_INPUT_PLACEHOLD_GRAY;
    _contentL.font=HDLEZ_Get_FontRegularWithSize(HDLEZ_FontSize_12);
    
    //下划线
    _lineV=[[UIView alloc] init];
    [self addSubview:_lineV];
    [_lineV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(16);
        make.bottom.equalTo(self);
        make.right.equalTo(self).offset(-16);
        make.height.mas_equalTo(1);
    }];
    _lineV.backgroundColor=HDLEZ_COLOR_BACKGROUND_LINE;
    
    //按钮
    _button=[[UIButton alloc] init];
    [self addSubview:_button];
    [_button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.equalTo(self);
    }];
    [_button addTarget:self action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside];
    
 
}
 
/*点击按钮
 */
-(void)buttonClick{
    if (self.clickBtn) {
        self.clickBtn();
    }
}
 
/*隐藏右侧箭头
 */
-(void)hideNextImg{
    [_nextImgV mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(0);
    }];
    [_nextImgV setHidden:YES];
}
 
-(void)setTitle:(NSString *)title{
    _title=title;
    CGSize titleSize=[title sizeWithAttributes:@{NSFontAttributeName:HDLEZ_Get_FontRegularWithSize(HDLEZ_FontSize_14)}];
    [_titleL mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(titleSize.width+5);
    }];
    _titleL.text=title;
 
}
@end