123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- //
- // XYSetSkillInfoTableViewCell.m
- // Starbuds
- //
- // Created by 翟玉磊 on 2020/10/29.
- // Copyright © 2020 翟玉磊. All rights reserved.
- //
- #import "XYSetSkillInfoTableViewCell.h"
- #import "XYSetSkillInfoCellModel.h"
- @interface XYSetSkillInfoTableViewCell ()
- @property (nonatomic, strong) UILabel *titleLabel;
- @property (nonatomic, strong) UILabel *contentLabel;
- @property (nonatomic, strong) UIView *line;
- @end
- @implementation XYSetSkillInfoTableViewCell
- #pragma mark — Public
- + (instancetype)cellWithTableView:(UITableView *)tableView {
- static NSString *cellId = @"XYSetSkillInfoTableViewCell";
- XYSetSkillInfoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
- if (cell == nil) {
- cell = [[XYSetSkillInfoTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- }
- return cell;
- }
- - (void)configureModel:(XYSetSkillInfoCellModel *)model {
- self.titleLabel.text = model.title;
- self.contentLabel.text = model.content;
- self.contentLabel.textColor = model.contentColor;
-
- self.line.hidden = !model.isShowBottomLine;
- }
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
- if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
-
- [self setupUI];
- }
- return self;
- }
- - (void)setupUI {
-
- self.contentView.backgroundColor = Color_White;
-
- [self.contentView addSubview:self.titleLabel];
- [self.contentView addSubview:self.contentLabel];
- [self.contentView addSubview:self.line];
-
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView).offset(20.0f);
- make.centerY.equalTo(self.contentView);
- }];
- [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.contentView).offset(-20.0f);
- make.centerY.equalTo(self.contentView);
- }];
- [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.equalTo(self.contentView);
- make.height.equalTo(@(LINE_HEIGHT));
- }];
- }
- #pragma mark — Getter
- - (UILabel *)titleLabel {
- if (!_titleLabel) {
- _titleLabel = [UILabel createLabelTextColor:Color_TextFont fount:Font(14)];
- }
- return _titleLabel;
- }
- - (UILabel *)contentLabel {
- if (!_contentLabel) {
- _contentLabel = [UILabel createLabelTextColor:Color_TextFont fount:Font(14)];
- _contentLabel.textAlignment = NSTextAlignmentRight;
- }
- return _contentLabel;
- }
- - (UIView *)line {
- if (!_line) {
- _line = [UIView new];
- _line.backgroundColor = Color_line;
- }
- return _line;
- }
- - (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
- }
- @end
|