ASSettingListCell.m 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. //
  2. // ASSettingListCell.m
  3. // Asteria
  4. //
  5. // Created by iOS on 2023/7/5.
  6. //
  7. #import "ASSettingListCell.h"
  8. @interface ASSettingListCell ()
  9. @property (nonatomic, strong) UIView *bgV;
  10. @property (nonatomic, strong) UILabel *titleLb;
  11. @property (nonatomic, strong) UILabel *pointsLb;
  12. @end
  13. @implementation ASSettingListCell
  14. - (void)setTitle:(NSString *)title points:(NSString *)points enable:(BOOL)flag {
  15. self.titleLb.text = title;
  16. self.pointsLb.text = points;
  17. self.moreIcon.image = flag ? [UIImage imageNamed:@"uc_more"] : nil;
  18. self.titleLb.textColor = [UIColor.blackColor colorWithAlphaComponent:flag ? 1 : 0.6];
  19. self.pointsLb.textColor = [UIColor.blackColor colorWithAlphaComponent:flag ? 1 : 0.6];
  20. }
  21. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  22. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  23. if (self) {
  24. [self confgSubV];
  25. }
  26. return self;
  27. }
  28. - (void)awakeFromNib {
  29. [super awakeFromNib];
  30. // Initialization code
  31. }
  32. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  33. [super setSelected:selected animated:animated];
  34. // Configure the view for the selected state
  35. }
  36. - (void)confgSubV {
  37. self.selectionStyle = UITableViewCellSelectionStyleNone;
  38. self.contentView.backgroundColor = _F8F8F8;
  39. [self.contentView addSubview:self.bgV];
  40. [self.bgV addSubview:self.titleLb];
  41. [self.bgV addSubview:self.pointsLb];
  42. [self.bgV addSubview:self.moreIcon];
  43. [self.bgV addSubview:self.switchBtn];
  44. [self.bgV mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.top.equalTo(self.contentView).offset(10);
  46. make.left.equalTo(self.contentView).offset(10);
  47. make.right.equalTo(self.contentView).offset(-10);
  48. make.bottom.equalTo(self.contentView);
  49. make.height.equalTo(@60);
  50. }];
  51. [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
  52. make.left.top.equalTo(self.bgV).offset(10);
  53. make.centerY.equalTo(self.bgV);
  54. }];
  55. [self.moreIcon mas_makeConstraints:^(MASConstraintMaker *make) {
  56. make.right.equalTo(self.bgV).offset(-12);
  57. make.width.height.equalTo(@13);
  58. make.centerY.equalTo(self.titleLb);
  59. }];
  60. [self.pointsLb mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.right.equalTo(self.moreIcon.mas_left).offset(-10);
  62. make.left.equalTo(self.titleLb.mas_right).offset(30);
  63. make.centerY.equalTo(self.titleLb);
  64. make.width.greaterThanOrEqualTo(@80);
  65. make.height.equalTo(@14);
  66. }];
  67. [self.titleLb setContentHuggingPriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
  68. [self.titleLb setContentHuggingPriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisVertical];
  69. [self.pointsLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  70. [self.pointsLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
  71. [self.switchBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  72. make.right.equalTo(self.bgV).offset(-10);
  73. make.centerY.equalTo(self.bgV);
  74. make.width.equalTo(@60);
  75. make.height.equalTo(@32);
  76. }];
  77. }
  78. - (UILabel *)titleLb {
  79. if (!_titleLb) {
  80. UILabel *lb = [UILabel new];
  81. lb.textColor = Col_000;
  82. lb.font = [UIFont fontWithName:Rob_Regular size:14];
  83. lb.numberOfLines = 0;
  84. _titleLb = lb;
  85. }
  86. return _titleLb;
  87. }
  88. - (UILabel *)pointsLb {
  89. if (!_pointsLb) {
  90. UILabel *lb = [UILabel new];
  91. lb.textColor = Col_000;
  92. lb.textAlignment = NSTextAlignmentRight;
  93. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  94. lb.numberOfLines = 1;
  95. _pointsLb = lb;
  96. }
  97. return _pointsLb;
  98. }
  99. - (UIImageView *)moreIcon {
  100. if (!_moreIcon) {
  101. UIImageView *v = [[UIImageView alloc] init];
  102. v.contentMode = UIViewContentModeScaleAspectFit;
  103. v.image = [UIImage imageNamed:@"uc_more"];
  104. _moreIcon = v;
  105. }
  106. return _moreIcon;
  107. }
  108. -(UIView *)bgV {
  109. if (!_bgV) {
  110. UIView *v = [UIView new];
  111. v.backgroundColor = Col_FFF;
  112. v.layer.cornerRadius = 4;
  113. v.layer.masksToBounds = true;
  114. _bgV = v;
  115. }
  116. return _bgV;
  117. }
  118. -(KWSwitchButton *)switchBtn {
  119. if (!_switchBtn) {
  120. KWSwitchButton *btn = [[KWSwitchButton alloc] init];
  121. btn.openColor = _32CFB0;
  122. btn.hidden = true;
  123. _switchBtn = btn;
  124. }
  125. return _switchBtn;
  126. }
  127. @end