XYModifyAlertEditInfoTableViewCell.m 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. //
  2. // XYModifyInfoSectionTableViewCell.m
  3. // Starbuds
  4. //
  5. // Created by 翟玉磊 on 2020/3/30.
  6. // Copyright © 2020 翟玉磊. All rights reserved.
  7. //
  8. #import "XYModifyAlertEditInfoTableViewCell.h"
  9. #import "XYModifyUserInfoListModel.h"
  10. #import "XYModifyUserInfoViewController.h"
  11. @interface XYModifyAlertEditInfoTableViewCell ()
  12. @property (nonatomic, readwrite, strong) UIView *shadowView;
  13. @property (nonatomic, readwrite, strong) UILabel *titleLabel;
  14. @property (nonatomic, readwrite, strong) UILabel *descLabel;
  15. @end
  16. @implementation XYModifyAlertEditInfoTableViewCell
  17. #pragma mark - Public Method
  18. + (instancetype)cellWithTableView:(UITableView *)tableView {
  19. static NSString * const cellId = @"XYModifyAlertEditInfoTableViewCell";
  20. XYModifyAlertEditInfoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
  21. if (cell == nil) {
  22. cell = [[XYModifyAlertEditInfoTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
  23. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  24. }
  25. return cell;
  26. }
  27. - (void)configureModel:(XYModifyUserInfoListModel *)model {
  28. self.titleLabel.text = [NSString stringWithFormat:@"根据系统评定,您的资料填写评分为:%d分 \n这样的分数,很难交到朋友哦~",[XYUserInfoManager nowUser].userScore];
  29. NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:self.titleLabel.text];
  30. [attributedString addAttributes:@{NSFontAttributeName:Font_B(16)} range:NSMakeRange(17, 4)];
  31. self.titleLabel.attributedText = attributedString;
  32. self.descLabel.text = @"完善资料";
  33. }
  34. #pragma mark - 初始化
  35. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  36. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  37. // 初始化
  38. [self _setup];
  39. // 创建自控制器
  40. [self _setupSubViews];
  41. // 布局子控件
  42. [self _makeSubViewsConstraints];
  43. }
  44. return self;
  45. }
  46. #pragma mark - 事件处理Or辅助方法
  47. - (void)shadowViewAction{
  48. XYModifyUserInfoViewController *controler = [XYModifyUserInfoViewController new];
  49. controler.infoType = ModifyUserInfo_Type_User;
  50. [self.viewController.navigationController pushViewController:controler animated:YES];
  51. }
  52. #pragma mark - Private Method
  53. - (void)_setup{
  54. self.backgroundColor = Color_Background;
  55. }
  56. #pragma mark - 创建子控件
  57. - (void)_setupSubViews{
  58. [self.contentView addSubview:self.shadowView];
  59. [self.contentView addSubview:self.titleLabel];
  60. [self.contentView addSubview:self.descLabel];
  61. kViewRadius(self.shadowView, 10);
  62. kViewBorderRadius(self.descLabel, 6, 1, Color_White);
  63. self.shadowView.backgroundColor = [UIColor colorGradientChangeWithSize:CGSizeMake(kScreenWidth-40, 80) direction:GradientChangeDirectionLevel startColor:ColorFromHexString(@"#5D26FF") endColor:ColorFromHexString(@"#9059FF")];
  64. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(shadowViewAction)];
  65. self.shadowView.userInteractionEnabled = YES;
  66. [self.shadowView addGestureRecognizer:tap];
  67. }
  68. #pragma mark - 布局子控件
  69. - (void)_makeSubViewsConstraints{
  70. [self.shadowView mas_makeConstraints:^(MASConstraintMaker *make) {
  71. make.left.equalTo(self.contentView.mas_left).offset(20);
  72. make.right.equalTo(self.contentView.mas_right).offset(-20);
  73. make.top.equalTo(self.contentView.mas_top).offset(10);
  74. make.bottom.equalTo(self.contentView.mas_bottom).offset(-10);
  75. }];
  76. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  77. make.left.equalTo(self.shadowView).offset(10);
  78. make.centerY.equalTo(self.shadowView);
  79. }];
  80. [self.descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  81. make.right.equalTo(self.shadowView.mas_right).offset(-10);
  82. make.centerY.equalTo(self.contentView);
  83. make.width.offset(60);
  84. make.height.offset(30);
  85. }];
  86. }
  87. - (void)awakeFromNib {
  88. [super awakeFromNib];
  89. // Initialization code
  90. }
  91. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  92. [super setSelected:selected animated:animated];
  93. // Configure the view for the selected state
  94. }
  95. - (UIView *)shadowView{
  96. if (!_shadowView) {
  97. _shadowView = [[UIView alloc] init];
  98. }
  99. return _shadowView;
  100. }
  101. - (UILabel *)titleLabel {
  102. if (!_titleLabel) {
  103. _titleLabel = [UILabel createLabelTextColor:Color_White fount:Font(12)];
  104. _titleLabel.numberOfLines = 0;
  105. }
  106. return _titleLabel;
  107. }
  108. - (UILabel *)descLabel {
  109. if (!_descLabel) {
  110. _descLabel = [UILabel createLabelTextColor:Color_White fount:Font(12)];
  111. _descLabel.textAlignment = NSTextAlignmentCenter;
  112. }
  113. return _descLabel;
  114. }
  115. @end