1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- //
- // ASHomeImgCell.m
- // Asteria
- //
- // Created by iOS on 2023/6/10.
- //
- #import "ASHomeImgCell.h"
- @interface ASHomeImgCell ()
- @property (nonatomic, strong) UIImageView *imgV;
- @property (nonatomic, strong) UIButton *bt;
- @end
- @implementation ASHomeImgCell
- - (void)setImgStr:(NSString *)imgStr {
- [self.imgV sd_setImageWithURL:[NSURL URLWithString:imgStr] placeholderImage:[UIImage imageNamed:@"product_defualtImg"]];
- }
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- [self loadSubV];
- }
- return self;
- }
- - (void)loadSubV {
- self.selectionStyle = UITableViewCellSelectionStyleNone;
- self.backgroundColor = _0E0E0F;
- [self.contentView addSubview:self.imgV];
- [self.imgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(self.contentView);
- make.width.equalTo(self.imgV.mas_height).multipliedBy(375.0/200);
- }];
- [self.contentView addSubview:self.bt];
- [self.bt mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(self.contentView);
- }];
- }
- - (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
- }
- - (UIImageView *)imgV {
- if (!_imgV) {
- UIImageView *v = [UIImageView baseImgV];
- v.contentMode = UIViewContentModeScaleAspectFill;
- v.clipsToBounds = true;
- _imgV = v;
- }
- return _imgV;
- }
- - (UIButton *)bt {
- if (!_bt) {
- UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
- [b addTarget:self action:@selector(btAction) forControlEvents:UIControlEventTouchUpInside];
- _bt = b;
- }
- return _bt;
- }
- - (void)btAction {
- if (self.tapImgBlock) {
- self.tapImgBlock();
- }
- }
- @end
|