YOUPAIProfileMenuItemContentCell.m 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. //
  2. // YOUPAIProfileMenuItemContentCell.m
  3. // MSYOUPAI
  4. //
  5. // Created by xiaohaoran on 2022/3/7.
  6. // Copyright © 2022 MS. All rights reserved.
  7. //
  8. #import "YOUPAIProfileMenuItemContentCell.h"
  9. #import "YOUPAIHRMedalView.h"
  10. @implementation YOUPAIProfileMenuItemContentCell
  11. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  12. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  13. self.selectionStyle = UITableViewCellSelectionStyleNone;
  14. [self youpaifinitialValue];
  15. [self youpaifinitUI];
  16. }
  17. return self;
  18. }
  19. - (void)youpaifinitialValue{
  20. self.youpaiplz_accessoryType = LZTableViewCellAccessoryNone;
  21. }
  22. -(void)setYoupaipisShow:(NSString*)isShow{
  23. _youpaipisShow = isShow;
  24. if ([self.youpaipisShow isEqualToString:@"1"]) {
  25. self.youpaipredView.hidden = NO;
  26. }else{
  27. self.youpaipredView.hidden = YES;
  28. }
  29. }
  30. - (void)youpaifinitUI{
  31. self.youpaipimgV = [[UIImageView alloc] init];
  32. [self.contentView addSubview:self.youpaipimgV];
  33. [self.youpaipimgV mas_makeConstraints:^(MASConstraintMaker *make) {
  34. make.left.offset(13.0f);
  35. make.centerY.mas_equalTo(0);
  36. make.width.height.offset(32.0f);
  37. }];
  38. self.youpaiptextL = [[UILabel alloc] init];
  39. self.youpaiptextL.font = LCFont(14.0f);
  40. self.youpaiptextL.textColor = LZ273145Color;
  41. [self.contentView addSubview:self.youpaiptextL];
  42. [self.youpaiptextL mas_makeConstraints:^(MASConstraintMaker *make) {
  43. make.left.equalTo(self.youpaipimgV.mas_right).offset(7.0f);
  44. make.centerY.mas_equalTo(0);
  45. }];
  46. self.youpaipsubTextL = [[UILabel alloc] init];
  47. self.youpaipsubTextL.font = LCFont(12.0f);
  48. self.youpaipsubTextL.textColor = HexColorFromRGB(0x9F9DA5);
  49. [self.contentView addSubview:self.youpaipsubTextL];
  50. [self.youpaipsubTextL mas_makeConstraints:^(MASConstraintMaker *make) {
  51. make.left.equalTo(self.youpaiptextL.mas_right).offset(3.0f);
  52. make.centerY.mas_equalTo(0);
  53. }];
  54. self.youpaiprightArrowImgV = [[UIImageView alloc] init];
  55. self.youpaiprightArrowImgV.image = [UIImage imageNamed:@"vqu_images_D_profile_item_arrow1"];
  56. self.youpaiprightArrowImgV.hidden = YES;
  57. [self.contentView addSubview:self.youpaiprightArrowImgV];
  58. [self.youpaiprightArrowImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  59. make.right.mas_equalTo(-13.0f);
  60. make.width.height.offset(10.0f);
  61. make.centerY.equalTo(0);
  62. }];
  63. self.youpaiprightLabel = [[UILabel alloc] init];
  64. self.youpaiprightLabel.font = LCFont(12.0f);
  65. self.youpaiprightLabel.textColor = HexColorFromRGB(0x9F9DA5);
  66. [self.contentView addSubview:self.youpaiprightLabel];
  67. [self.youpaiprightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.right.equalTo(self.youpaiprightArrowImgV.mas_left).offset(-10.0f);
  69. make.centerY.equalTo(0);
  70. }];
  71. self.youpaiprightLabel.hidden = YES;
  72. self.youpaiprightSwitch = [UIButton buttonWithType:UIButtonTypeCustom];
  73. [self.youpaiprightSwitch setImage:[UIImage imageNamed:@"vqu_images_ic_profile_siwch_on"] forState:UIControlStateSelected];
  74. [self.youpaiprightSwitch setImage:[UIImage imageNamed:@"vqu_images_ic_profile_siwch_off"] forState:UIControlStateNormal];
  75. self.youpaiprightSwitch.hidden = YES;
  76. [self.contentView addSubview:self.youpaiprightSwitch];
  77. [self.youpaiprightSwitch mas_makeConstraints:^(MASConstraintMaker *make) {
  78. make.right.offset(-20.0f);
  79. make.centerY.equalTo(0);
  80. make.size.mas_offset(CGSizeMake(27.5f, 44.0f));
  81. }];
  82. UIView *line = [[UIView alloc] init];
  83. self.line = line;
  84. line.backgroundColor = LZF5F4F7Color;
  85. [self.contentView addSubview:line];
  86. [line mas_makeConstraints:^(MASConstraintMaker *make) {
  87. make.left.offset(2.0f);
  88. make.right.offset(-2.0f);
  89. make.height.offset(0.5f);
  90. make.bottom.offset(0.0f);
  91. }];
  92. YOUPAILCBaseInfo *userinfo = [LCSaveModel getUserModel].youpaipuserinfo;
  93. self.youpaiprightWidth = 54;
  94. CGFloat width = 0;
  95. for (int i =0 ; i<userinfo.youpaipbadge_all.count; i++) {
  96. YOUPAILZVipCarModel *model = userinfo.youpaipbadge_all[i];
  97. width+=[model.youpaipwidth floatValue];
  98. self.youpaiprightWidth += [model.youpaipwidth floatValue];
  99. }
  100. YOUPAIHRMedalView *righMedaltView = [YOUPAIHRMedalView new];
  101. self.youpaiprighMedaltView = righMedaltView;
  102. [self.contentView addSubview:righMedaltView];
  103. [righMedaltView mas_makeConstraints:^(MASConstraintMaker *make) {
  104. make.centerY.mas_equalTo(0);
  105. make.right.equalTo(self.youpaiprightArrowImgV.mas_left).offset(-10.0f);
  106. make.size.mas_equalTo(CGSizeMake(width+5, 15));
  107. }];
  108. righMedaltView.youpaipinfoModel = userinfo;
  109. righMedaltView.hidden = YES;
  110. //未读红点
  111. UIView *redView = [UIView new];
  112. self.youpaipredView = redView;
  113. [self addSubview:redView];
  114. [redView mas_makeConstraints:^(MASConstraintMaker *make) {
  115. make.right.mas_equalTo(-40);
  116. make.centerY.mas_equalTo(righMedaltView);
  117. make.size.mas_equalTo(CGSizeMake(4, 4));
  118. }];
  119. redView.layer.cornerRadius = 2;
  120. redView.layer.masksToBounds = YES;
  121. redView.backgroundColor = LCRedColor;
  122. redView.hidden = YES;
  123. }
  124. - (void)setYoupaiplz_accessoryType:(LZTableViewCellAccessoryType)lz_accessoryType{
  125. self.youpaiprightSwitch.hidden = YES;
  126. self.youpaiprightArrowImgV.hidden = YES;
  127. _youpaiplz_accessoryType = lz_accessoryType;
  128. switch (lz_accessoryType) {
  129. case LZTableViewCellAccessoryNone:
  130. break;
  131. case LZTableViewCellAccessoryDisclosureIndicator:
  132. {
  133. self.youpaiprightArrowImgV.hidden = NO;
  134. }
  135. break;
  136. case LZTableViewCellAccessorySwitch:
  137. {
  138. self.youpaiprightSwitch.hidden = NO;
  139. }
  140. break;
  141. case LZTableViewCellAccessoryRightTitle:
  142. {
  143. self.youpaiprightLabel.hidden = NO;
  144. self.youpaiprightArrowImgV.hidden = NO;
  145. }
  146. break;
  147. case LZTableViewCellAccessoryRightImage:
  148. {
  149. self.youpaiprighMedaltView.hidden = NO;
  150. self.youpaiprightArrowImgV.hidden = NO;
  151. [self.youpaipredView mas_updateConstraints:^(MASConstraintMaker *make) {
  152. make.right.mas_equalTo(-self.youpaiprightWidth);
  153. }];
  154. }
  155. break;
  156. default:
  157. break;
  158. }
  159. }
  160. @end