// // XYModifyInfoSectionTableViewCell.m // Starbuds // // Created by 翟玉磊 on 2020/3/30. // Copyright © 2020 翟玉磊. All rights reserved. // #import "XYModifyAlertEditInfoTableViewCell.h" #import "XYModifyUserInfoListModel.h" #import "XYModifyUserInfoViewController.h" @interface XYModifyAlertEditInfoTableViewCell () @property (nonatomic, readwrite, strong) UIView *shadowView; @property (nonatomic, readwrite, strong) UILabel *titleLabel; @property (nonatomic, readwrite, strong) UILabel *descLabel; @end @implementation XYModifyAlertEditInfoTableViewCell #pragma mark - Public Method + (instancetype)cellWithTableView:(UITableView *)tableView { static NSString * const cellId = @"XYModifyAlertEditInfoTableViewCell"; XYModifyAlertEditInfoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId]; if (cell == nil) { cell = [[XYModifyAlertEditInfoTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId]; cell.selectionStyle = UITableViewCellSelectionStyleNone; } return cell; } - (void)configureModel:(XYModifyUserInfoListModel *)model { self.titleLabel.text = [NSString stringWithFormat:@"根据系统评定,您的资料填写评分为:%d分 \n这样的分数,很难交到朋友哦~",[XYUserInfoManager nowUser].userScore]; NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:self.titleLabel.text]; [attributedString addAttributes:@{NSFontAttributeName:Font_B(16)} range:NSMakeRange(17, 4)]; self.titleLabel.attributedText = attributedString; self.descLabel.text = @"完善资料"; } #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辅助方法 - (void)shadowViewAction{ XYModifyUserInfoViewController *controler = [XYModifyUserInfoViewController new]; controler.infoType = ModifyUserInfo_Type_User; [self.viewController.navigationController pushViewController:controler animated:YES]; } #pragma mark - Private Method - (void)_setup{ self.backgroundColor = Color_Background; } #pragma mark - 创建子控件 - (void)_setupSubViews{ [self.contentView addSubview:self.shadowView]; [self.contentView addSubview:self.titleLabel]; [self.contentView addSubview:self.descLabel]; kViewRadius(self.shadowView, 10); kViewBorderRadius(self.descLabel, 6, 1, Color_White); self.shadowView.backgroundColor = [UIColor colorGradientChangeWithSize:CGSizeMake(kScreenWidth-40, 80) direction:GradientChangeDirectionLevel startColor:ColorFromHexString(@"#5D26FF") endColor:ColorFromHexString(@"#9059FF")]; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(shadowViewAction)]; self.shadowView.userInteractionEnabled = YES; [self.shadowView addGestureRecognizer:tap]; } #pragma mark - 布局子控件 - (void)_makeSubViewsConstraints{ [self.shadowView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.contentView.mas_left).offset(20); make.right.equalTo(self.contentView.mas_right).offset(-20); make.top.equalTo(self.contentView.mas_top).offset(10); make.bottom.equalTo(self.contentView.mas_bottom).offset(-10); }]; [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.shadowView).offset(10); make.centerY.equalTo(self.shadowView); }]; [self.descLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.shadowView.mas_right).offset(-10); make.centerY.equalTo(self.contentView); make.width.offset(60); make.height.offset(30); }]; } - (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 } - (UIView *)shadowView{ if (!_shadowView) { _shadowView = [[UIView alloc] init]; } return _shadowView; } - (UILabel *)titleLabel { if (!_titleLabel) { _titleLabel = [UILabel createLabelTextColor:Color_White fount:Font(12)]; _titleLabel.numberOfLines = 0; } return _titleLabel; } - (UILabel *)descLabel { if (!_descLabel) { _descLabel = [UILabel createLabelTextColor:Color_White fount:Font(12)]; _descLabel.textAlignment = NSTextAlignmentCenter; } return _descLabel; } @end