MGShowVIPCell.m 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. //
  2. // MGShowVIPCell.m
  3. // BuguLive
  4. //
  5. // Created by 宋晨光 on 2019/12/19.
  6. // Copyright © 2019 xfg. All rights reserved.
  7. //
  8. #import "MGShowVIPCell.h"
  9. @implementation MGShowVIPCell
  10. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  11. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  12. [self setUpView];
  13. [self resetView];
  14. }
  15. return self;
  16. }
  17. -(void)setUpView{
  18. UIImageView *headImgView = [UIImageView new];
  19. [headImgView setImage:[UIImage imageNamed:@"live_wish_gift_addBGView"]];
  20. _headImgView = headImgView;
  21. UILabel *nickNameL = [UILabel new];
  22. nickNameL.textColor = kBlackColor;
  23. nickNameL.font = [UIFont systemFontOfSize:14];
  24. _nickNameL = nickNameL;
  25. UIImageView *sexImgView = [UIImageView new];
  26. [sexImgView setImage:[UIImage imageNamed:@"live_wish_gift_addBGView"]];
  27. _sexImgView = sexImgView;
  28. UIImageView *levelImgView = [UIImageView new];
  29. [levelImgView setImage:[UIImage imageNamed:@"live_wish_gift_addBGView"]];
  30. _levelImgView = levelImgView;
  31. [self.contentView addSubview:headImgView];
  32. [self.contentView addSubview:nickNameL];
  33. [self.contentView addSubview:sexImgView];
  34. [self.contentView addSubview:levelImgView];
  35. }
  36. -(void)resetView{
  37. self.headImgView.frame = CGRectMake(kRealValue(11), kRealValue(7), kRealValue(40), kRealValue(40));
  38. self.headImgView.layer.masksToBounds = YES;
  39. self.headImgView.layer.cornerRadius = kRealValue(40 / 2);
  40. [self.nickNameL sizeToFit];
  41. self.nickNameL.left = self.headImgView.right + kRealValue(15);
  42. self.nickNameL.centerY = self.headImgView.centerY;
  43. self.sexImgView.frame = CGRectMake(self.nickNameL.right + kRealValue(5), 0, kRealValue(10), kRealValue(10));
  44. self.levelImgView.frame = CGRectMake(kScreenW - kRealValue(43) - kRealValue(10), 0, kRealValue(43), kRealValue(20));
  45. self.levelImgView.centerY = self.sexImgView.centerY = self.nickNameL.centerY;
  46. }
  47. -(void)resetModel:(MGShowVipModel *)model{
  48. if (model.is_noble_stealth.intValue == 1) {
  49. [self.headImgView sd_setImageWithURL:nil placeholderImage:kDefaultNobleMysteriousHeadImg];
  50. self.nickNameL.text = ASLocalizedString(@"神秘人");
  51. self.sexImgView.hidden = YES;
  52. [self.levelImgView sd_setImageWithURL:[NSURL URLWithString:model.noble_icon] placeholderImage:nil];
  53. }else{
  54. self.sexImgView.hidden = NO;
  55. [self.headImgView sd_setImageWithURL:[NSURL URLWithString:model.head_image]];
  56. self.nickNameL.text = model.nick_name;
  57. self.sexImgView.image = [model.sex isEqualToString:@"1"] ? [UIImage imageNamed:@"dy_sex_male"] : [UIImage imageNamed:@"dy_sex_female"];
  58. [self.levelImgView sd_setImageWithURL:[NSURL URLWithString:model.noble_icon] placeholderImage:nil];
  59. }
  60. [self resetView];
  61. }
  62. @end