123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- //
- // XYModifyInfoSectionTableViewCell.m
- // Starbuds
- //
- // Created by 翟玉磊 on 2020/3/30.
- // Copyright © 2020 翟玉磊. All rights reserved.
- //
- #import "XYModifyInfoSectionTableViewCell.h"
- #import "XYModifyUserInfoListModel.h"
- @interface XYModifyInfoSectionTableViewCell ()
- @property (nonatomic, readwrite, strong) UILabel *titleLabel;
- @property (nonatomic, readwrite, strong) UILabel *descLabel;
- @end
- @implementation XYModifyInfoSectionTableViewCell
- #pragma mark - Public Method
- + (instancetype)cellWithTableView:(UITableView *)tableView {
- static NSString * const cellId = @"XYModifyInfoSectionTableViewCell";
- XYModifyInfoSectionTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
- if (cell == nil) {
- cell = [[XYModifyInfoSectionTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- }
- return cell;
- }
- - (void)configureModel:(XYModifyUserInfoListModel *)model {
- self.titleLabel.text = model.groupName;
- if (model.userInfoType == ModifyUserInfo_Type_Main) {
- self.backgroundColor = Color_White;
- self.descLabel.hidden = YES;
- self.titleLabel.textColor = [UIColor colorWithHexString:@"#313233" alpha:1];
- self.titleLabel.font = Font_B(16);
- [self.titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView).offset(SPACING_EDGE);
- make.bottom.equalTo(self.contentView);
- }];
- }else{
- self.titleLabel.textColor = Color_TextGray;
- self.titleLabel.font = Font(14);
- self.descLabel.hidden = NO;
- self.descLabel.text = [NSString stringWithFormat:@"%ld%@完成",(long)model.groupScore,@"%"];
- if (model.groupScore < 0) {
- self.descLabel.hidden = YES;
- }else{
- self.descLabel.hidden = NO;
- }
- }
- }
- #pragma mark - 初始化
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
-
- if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
- // 初始化
- [self _setup];
-
- // 创建自控制器
- [self _setupSubViews];
-
- // 布局子控件
- [self _makeSubViewsConstraints];
- }
- return self;
- }
- #pragma mark - 事件处理Or辅助方法
- #pragma mark - Private Method
- - (void)_setup{
- self.backgroundColor = Color_Background;
- }
- #pragma mark - 创建子控件
- - (void)_setupSubViews{
- [self.contentView addSubview:self.titleLabel];
- [self.contentView addSubview:self.descLabel];
- }
- #pragma mark - 布局子控件
- - (void)_makeSubViewsConstraints{
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView).offset(SPACING_EDGE);
- make.centerY.equalTo(self.contentView);
- make.width.lessThanOrEqualTo(@150.0f);
- }];
- [self.descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.titleLabel.mas_right).offset(10);
- make.centerY.equalTo(self.contentView);
- make.right.lessThanOrEqualTo(self.contentView).offset(-SPACING_EDGE);
- }];
- }
- - (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
- }
- - (UILabel *)titleLabel {
- if (!_titleLabel) {
- _titleLabel = [UILabel createLabelTextColor:Color_TextGray fount:Font(14)];
- }
- return _titleLabel;
- }
- - (UILabel *)descLabel {
- if (!_descLabel) {
- _descLabel = [UILabel createLabelTextColor:Color_TextGray fount:Font(11)];
- }
- return _descLabel;
- }
- @end
|