SRedBagViewCell.m 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //
  2. // SRedBagViewCell.m
  3. // BuguLive
  4. //
  5. // Created by 丁凯 on 2017/7/15.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. //
  8. #import "SRedBagViewCell.h"
  9. @implementation SRedBagViewCell
  10. - (void)awakeFromNib
  11. {
  12. [super awakeFromNib];
  13. self.headView.layer.cornerRadius = 18;
  14. self.headView.layer.masksToBounds = YES;
  15. self.nameLabel.lineBreakMode = NSLineBreakByTruncatingTail;
  16. self.lineView.backgroundColor = kAppSpaceColor4;
  17. self.lineView.hidden = YES;
  18. self.sexView.hidden = YES;
  19. self.contentView.backgroundColor = kClearColor;
  20. self.backgroundColor = kClearColor;
  21. self.comDiamond1.hidden = YES;
  22. }
  23. - (void)creatCellWithModel:(CustomMessageModel *)model andRow:(int)row
  24. {
  25. NSString *string1 = model.nick_name;
  26. if (string1.length > 0)
  27. {
  28. NSMutableAttributedString *attr1 = [[NSMutableAttributedString alloc] initWithString:string1];
  29. [attr1 setAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14.0]} range:NSMakeRange(0, string1.length)];
  30. CGFloat width =[string1 sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]}].width;
  31. if (width+120+32 > self.width)
  32. {
  33. width = self.width-120-32;
  34. }
  35. CGRect rect = self.nameLabel.frame;
  36. rect.size.width = width;
  37. self.nameLabel.frame = rect;
  38. self.nameLabel.attributedText = attr1;
  39. }
  40. self.moneyLabel.text = [NSString stringWithFormat:ASLocalizedString(@"%d钻石"),(int)model.diamonds];
  41. if (row == 0)
  42. {
  43. self.goldView.hidden = NO;
  44. self.moneyLabelTopHeight.constant = 6;
  45. self.goldViewTopHeight.constant = 7;
  46. }else
  47. {
  48. self.goldView.hidden = YES;
  49. self.moneyLabelTopHeight.constant = 18;
  50. self.goldViewTopHeight.constant = 19;
  51. }
  52. if ([model.sex isEqualToString:@"1"])
  53. {
  54. self.sexView.image = [UIImage imageNamed:@"com_male_selected"];
  55. }else
  56. {
  57. self.sexView.image = [UIImage imageNamed:@"com_female_selected"];
  58. }
  59. [self.headView sd_setImageWithURL:[NSURL URLWithString:model.head_image] placeholderImage:kDefaultPreloadHeadImg];
  60. }
  61. @end