// // DrawerCell.m // smartRhino // // Created by tederen on 2019/10/21. // Copyright © 2019 tederen. All rights reserved. // #import "DrawerCell.h" @interface DrawerCell () @property (nonatomic, strong) UILabel *titleLabel; @property (nonatomic, strong) UIImageView *avatarImageView; @property (nonatomic, strong) UIImageView *arrowImageView; @end @implementation DrawerCell - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { // Initialization code [self.contentView addSubview:self.avatarImageView]; [self.contentView addSubview:self.titleLabel]; [self.contentView addSubview:self.arrowImageView]; [_avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.leading.equalTo(self.contentView).offset(33); make.centerY.equalTo(self.contentView); }]; [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.leading.equalTo(self.contentView).offset(80); make.trailing.equalTo(_arrowImageView.mas_leading).offset(23); make.centerY.equalTo(_avatarImageView); }]; [_arrowImageView mas_makeConstraints:^(MASConstraintMaker *make){ make.trailing.equalTo(self.contentView).offset(-23); make.centerY.equalTo(self.contentView); make.size.mas_equalTo(CGSizeMake(7, 12)); }]; } return self; } #pragma mark - publicMethod - (void)loadCellDataWithTitle:(NSString *)title imageName:(NSString *)imageName { _titleLabel.text = title; [_titleLabel sizeToFit]; [_avatarImageView setImage:IMG(imageName)]; [_avatarImageView mas_updateConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(IMG(imageName).size); }]; } #pragma mark - setter/getter - (UILabel *)titleLabel { if (!_titleLabel) { _titleLabel = [UILabel new]; _titleLabel.textColor = UIColorHex(232323); _titleLabel.font = [UIFont systemFontOfSize:17]; } return _titleLabel; } - (UIImageView *)avatarImageView { if (!_avatarImageView) { _avatarImageView = [UIImageView new]; _avatarImageView.contentMode = UIViewContentModeScaleAspectFill; } return _avatarImageView; } - (UIImageView *)arrowImageView { if (!_arrowImageView) { _arrowImageView = [[UIImageView alloc] initWithImage:IMG(@"icon_arrowRight")]; } return _arrowImageView; } @end