// // ASEnterItemV.m // Asteria // // Created by iOS on 2023/5/15. // #import "ASEnterItemV.h" @implementation ASEnterItemV - (void)setData:(NSString *)title icon:(UIImage *)img { self.imageV.image = img; self.titleLb.text = title; } - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self configSubV]; } return self; } - (void)configSubV { [self addSubview:self.imageV]; [self addSubview:self.titleLb]; [self addSubview:self.btn]; [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self).offset(5); make.right.equalTo(self).offset(-5); make.bottom.equalTo(self).offset(-5); make.height.equalTo(@14); }]; [self.imageV mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.titleLb); make.top.equalTo(self).offset(5); make.bottom.equalTo(self.titleLb.mas_top).offset(-10); }]; [self.btn mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(self); }]; } -(void)btnAction { if (self.clickCallBack) { self.clickCallBack(); } } -(UIButton *)btn { if (!_btn) { _btn = [UIButton buttonWithType:UIButtonTypeCustom]; [_btn addTarget:self action:@selector(btnAction) forControlEvents:UIControlEventTouchUpInside]; } return _btn; } - (UIImageView *)imageV { if (!_imageV) { UIImageView *imgV = [[UIImageView alloc] init]; imgV.contentMode = UIViewContentModeScaleAspectFit; _imageV = imgV; } return _imageV; } - (UILabel *)titleLb { if (!_titleLb) { UILabel *lb = [[UILabel alloc] init]; lb.font = [UIFont fontWithName:Rob_Regular size:12]; lb.textColor = UIColor.blackColor; lb.textAlignment = NSTextAlignmentCenter; _titleLb = lb; } return _titleLb; } @end