//
|
// HDLEZMirrorFlipView.m
|
// EZSDK
|
//
|
// Created by Davin on 2024/11/6.
|
//
|
|
#import "HDLEZMirrorFlipView.h"
|
|
@interface HDLEZMirrorFlipView ()
|
|
@property (nonatomic, strong) UIView *baseView;
|
@property (nonatomic, strong) UILabel *titleLabel;
|
@property (nonatomic, strong) UIImageView *rightIcon;
|
@property (nonatomic, strong) UILabel *subTitleLabel;
|
|
@property (nonatomic, copy) void(^clickBlock)(void);
|
|
@end
|
|
@implementation HDLEZMirrorFlipView
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
if (self = [super initWithFrame:frame]) {
|
[self createSubviews];
|
}
|
return self;
|
}
|
|
- (void)createSubviews {
|
self.backgroundColor = [UIColor clearColor];
|
[self addSubview:self.baseView];
|
[self addSubview:self.titleLabel];
|
[self addSubview:self.rightIcon];
|
[self addSubview:self.subTitleLabel];
|
|
[self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.mas_equalTo(self.mas_top);
|
make.left.mas_equalTo(self.mas_left);
|
make.right.mas_equalTo(self.mas_right);
|
make.height.mas_equalTo(50.);
|
}];
|
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.left.mas_equalTo(self.baseView.mas_left).offset(16.);
|
make.centerY.mas_equalTo(self.baseView.mas_centerY);
|
}];
|
|
[self.rightIcon mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.right.mas_equalTo(self.mas_right).offset(-16.);
|
make.centerY.mas_equalTo(self.baseView.mas_centerY);
|
make.width.mas_equalTo(16);
|
make.height.mas_equalTo(16);
|
}];
|
|
[self.subTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.mas_equalTo(self.baseView.mas_bottom);
|
make.left.mas_equalTo(self.titleLabel.mas_left);
|
make.height.mas_equalTo(50.);
|
}];
|
|
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(mirrorFlipAction)];
|
[self.baseView addGestureRecognizer:tapGesture];
|
}
|
|
#pragma mark - PublishMethod
|
/// 配置镜像翻转信息
|
/// - Parameters:
|
/// - title: 标题
|
/// - subTitle: 子标题
|
/// - clickResult: 点击回调
|
- (void)configTitle:(NSString *)title subTitle:(NSString *)subTitle click:(void(^)(void))clickResult {
|
self.titleLabel.text = title;
|
self.subTitleLabel.text = subTitle;
|
self.clickBlock = clickResult;
|
}
|
|
#pragma mark - PrivateMethod
|
- (void)mirrorFlipAction {
|
if (self.clickBlock) {
|
self.clickBlock();
|
}
|
}
|
|
#pragma mark - Getter
|
- (UIView *)baseView {
|
if (!_baseView) {
|
_baseView = [[UIView alloc] init];
|
_baseView.backgroundColor = HDLEZ_COLOR_VIEW_FOREGROUND;
|
}
|
return _baseView;
|
}
|
|
- (UILabel *)titleLabel {
|
if (!_titleLabel) {
|
_titleLabel=[[UILabel alloc] init];
|
_titleLabel.font = HDLEZ_Get_FontRegularWithSize(HDLEZ_FontSize_16);
|
_titleLabel.textColor=HDLEZHEXCOLOR(0x1B2D4D, 1.0);;
|
}
|
return _titleLabel;
|
}
|
|
- (UIImageView *)rightIcon {
|
if (!_rightIcon) {
|
_rightIcon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"hdl_ez_list_next"]];
|
_rightIcon.contentMode = UIViewContentModeScaleAspectFill;
|
_rightIcon.backgroundColor = UIColor.clearColor;
|
}
|
return _rightIcon;
|
}
|
|
- (UILabel *)subTitleLabel {
|
if (!_subTitleLabel) {
|
_subTitleLabel=[[UILabel alloc] init];
|
_subTitleLabel.font = HDLEZ_Get_FontRegularWithSize(HDLEZ_FontSize_14);
|
_subTitleLabel.textColor=HDLEZ_COLOR_TEXT_GRAY;
|
}
|
return _subTitleLabel;
|
}
|
|
@end
|