XYPersinalContentOpenVipTableViewCell.m 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. //
  2. // XYPersinalContentOpenVipTableViewCell.m
  3. // Starbuds
  4. //
  5. // Created by 翟玉磊 on 2020/4/10.
  6. // Copyright © 2020 翟玉磊. All rights reserved.
  7. //
  8. #import "XYPersinalContentOpenVipTableViewCell.h"
  9. #import "XYPersonalCenterListModel.h"
  10. @interface XYPersinalContentOpenVipTableViewCell ()
  11. @property (nonatomic, readwrite, strong) UIView *infoView;
  12. @property (nonatomic, readwrite, strong) UIImageView *bgImageView;
  13. @property (nonatomic, readwrite, strong) UIImageView *titleImageView;
  14. @property (nonatomic, readwrite, strong) UILabel *titleLabel;
  15. @property (nonatomic, readwrite, strong) UIImageView *moreImageView;
  16. @property (nonatomic, readwrite, strong) UILabel *contentLabel;
  17. @end
  18. @implementation XYPersinalContentOpenVipTableViewCell
  19. #pragma mark - Public Method
  20. + (instancetype)cellWithTableView:(UITableView *)tableView {
  21. static NSString * const cellId = @"XYPersinalContentOpenVipTableViewCell";
  22. XYPersinalContentOpenVipTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
  23. if (cell == nil) {
  24. cell = [[XYPersinalContentOpenVipTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
  25. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  26. }
  27. return cell;
  28. }
  29. - (void)configureModel:(XYPersonalCenterListModel *)model {
  30. self.titleImageView.image = ImageNamed(model.iconName);
  31. self.titleLabel.text = model.title;
  32. self.contentLabel.text = model.content;
  33. self.moreImageView.hidden = !model.isShowMoreImage;
  34. }
  35. - (void)setIndexPath:(NSIndexPath *)indexPath rowsInSection:(NSInteger)rows {
  36. }
  37. #pragma mark - 初始化
  38. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  39. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  40. // 初始化
  41. [self _setup];
  42. // 创建自控制器
  43. [self _setupSubViews];
  44. // 布局子控件
  45. [self _makeSubViewsConstraints];
  46. }
  47. return self;
  48. }
  49. #pragma mark - 事件处理Or辅助方法
  50. #pragma mark - Private Method
  51. - (void)_setup{
  52. self.backgroundColor = UIColor.whiteColor;
  53. }
  54. #pragma mark - 创建子控件
  55. - (void)_setupSubViews{
  56. [self.contentView addSubview:self.infoView];
  57. [self.infoView addSubview:self.bgImageView];
  58. [self.infoView addSubview:self.titleImageView];
  59. [self.infoView addSubview:self.titleLabel];
  60. [self.infoView addSubview:self.moreImageView];
  61. [self.infoView addSubview:self.contentLabel];
  62. }
  63. #pragma mark - 布局子控件
  64. - (void)_makeSubViewsConstraints{
  65. [self.infoView mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.left.equalTo(self.contentView);
  67. make.right.equalTo(self.contentView);
  68. make.top.equalTo(self.contentView);
  69. make.bottom.equalTo(self.contentView);
  70. }];
  71. [self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  72. make.edges.equalTo(self.infoView);
  73. }];
  74. [self.titleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  75. make.left.equalTo(self.infoView).offset(20.0f);
  76. make.centerY.equalTo(self.infoView);
  77. make.width.equalTo(@20.0f);
  78. make.height.equalTo(@18.0f);
  79. }];
  80. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  81. make.left.equalTo(self.titleImageView.mas_right).offset(6.0f);
  82. make.centerY.equalTo(self.infoView);
  83. make.height.equalTo(@21.0f);
  84. }];
  85. [self.moreImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  86. make.right.equalTo(self.infoView).offset(-20.0f);
  87. make.centerY.equalTo(self.infoView);
  88. make.width.height.equalTo(@13.0f);
  89. }];
  90. [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  91. make.right.equalTo(self.moreImageView.mas_left).offset(-8.0f);
  92. make.centerY.equalTo(self.infoView);
  93. }];
  94. [self.infoView addViewBorder:Color_Clear redian:8];
  95. }
  96. - (void)awakeFromNib {
  97. [super awakeFromNib];
  98. // Initialization code
  99. }
  100. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  101. [super setSelected:selected animated:animated];
  102. // Configure the view for the selected state
  103. }
  104. - (UIView *)infoView {
  105. if (!_infoView) {
  106. _infoView = [UIView new];
  107. _infoView.backgroundColor = Color_Clear;
  108. }
  109. return _infoView;
  110. }
  111. - (UIImageView *)bgImageView {
  112. if (!_bgImageView) {
  113. _bgImageView = [UIImageView new];
  114. _bgImageView.image = ImageNamed(@"icon_my_novip_bg");
  115. }
  116. return _bgImageView;
  117. }
  118. - (UIImageView *)titleImageView {
  119. if (!_titleImageView) {
  120. _titleImageView = [UIImageView new];
  121. }
  122. return _titleImageView;
  123. }
  124. - (UILabel *)titleLabel {
  125. if (!_titleLabel) {
  126. _titleLabel = [UILabel createLabelTextColor:ColorFromHexString(@"#FDE3A6") fount:Font_B(15)];
  127. }
  128. return _titleLabel;
  129. }
  130. - (UIImageView *)moreImageView {
  131. if (!_moreImageView) {
  132. _moreImageView = [UIImageView new];
  133. _moreImageView.image = ImageNamed(@"icon_my_vip_more");
  134. }
  135. return _moreImageView;
  136. }
  137. - (UILabel *)contentLabel {
  138. if (!_contentLabel) {
  139. _contentLabel = [UILabel createLabelTextColor:ColorFromHexString(@"#FDE3A6") fount:Font_B(12)];
  140. _contentLabel.textAlignment = NSTextAlignmentRight;
  141. }
  142. return _contentLabel;
  143. }
  144. @end