SocietyLeaveApplyCell.m 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. //
  2. // SocietyLeaveApplyCell.m
  3. // BuguLive
  4. //
  5. // Created by 王珂 on 17/1/22.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. //
  8. #import "SocietyLeaveApplyCell.h"
  9. #import "SocietyMemberModel.h"
  10. @interface SocietyLeaveApplyCell()
  11. @property (weak, nonatomic) IBOutlet UIImageView *headImgView;
  12. @property (weak, nonatomic) IBOutlet UILabel *nameLabel;
  13. @property (weak, nonatomic) IBOutlet UIImageView *sexImgView;
  14. @property (weak, nonatomic) IBOutlet UIImageView *rankImgView;
  15. @property (weak, nonatomic) IBOutlet UILabel *commentLabel;
  16. @property (weak, nonatomic) IBOutlet UIButton *agreeBtn;
  17. @property (weak, nonatomic) IBOutlet UIButton *refuseBtn;
  18. @property (nonatomic, strong) UILabel *nameLabel2;
  19. @property (nonatomic, strong) UIImageView *sexImgView2;
  20. @property (nonatomic, strong) UIImageView *rankImgView2;
  21. @property (nonatomic, copy) NSString *user_id;
  22. @end
  23. @implementation SocietyLeaveApplyCell
  24. + (instancetype)cellWithTableView:(UITableView *)tableView
  25. {
  26. static NSString *ID = @"SocietyLeaveApplyCell";
  27. SocietyLeaveApplyCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
  28. if (cell == nil) {
  29. cell = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([SocietyLeaveApplyCell class]) owner:nil options:nil] lastObject];
  30. }
  31. return cell;
  32. }
  33. - (void)awakeFromNib
  34. {
  35. [super awakeFromNib];
  36. self.nameLabel.hidden = YES;
  37. self.nameLabel2 = [[UILabel alloc]init];
  38. [self.contentView addSubview:self.nameLabel2];
  39. self.sexImgView.hidden = YES;
  40. self.sexImgView2 = [[UIImageView alloc]init];
  41. [self.contentView addSubview:self.sexImgView2];
  42. self.rankImgView.hidden = YES;
  43. self.rankImgView2 = [[UIImageView alloc]init];
  44. [self.contentView addSubview:self.rankImgView2];
  45. self.lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 59, kScreenW, 1)];
  46. self.lineView.backgroundColor = myTextColorLine5;
  47. [self.contentView addSubview:self.lineView];
  48. self.headImgView.layer.cornerRadius = 20;
  49. self.headImgView.layer.masksToBounds = YES;
  50. self.commentLabel.textColor = myTextColorLine3;
  51. self.agreeBtn.layer.cornerRadius = 15;
  52. self.agreeBtn.layer.masksToBounds = YES;
  53. self.agreeBtn.backgroundColor = kAppMainColor;
  54. self.refuseBtn.layer.cornerRadius = 15;
  55. self.refuseBtn.layer.masksToBounds = YES;
  56. self.refuseBtn.backgroundColor =kAppFamilyBtnColor;
  57. }
  58. - (void)creatCellWithModel:(SenderModel *)model WithRow:(int)row
  59. {
  60. self.user_id = model.user_id;
  61. [self.headImgView sd_setImageWithURL:[NSURL URLWithString:model.head_image] placeholderImage:kDefaultPreloadHeadImg];
  62. if (model.nick_name.length < 1)
  63. {
  64. model.nick_name = ASLocalizedString(@"暂时还未命名");
  65. }
  66. self.nameLabel2.textColor = kGrayTransparentColor6;
  67. NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:model.nick_name];
  68. [attr setAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:15.0]} range:NSMakeRange(0, model.nick_name.length)];
  69. CGFloat width =[model.nick_name sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]}].width;
  70. if (width+ 52 > kScreenW-200)//名字控件需要控制长度
  71. {
  72. width = kScreenW - 200-52;
  73. self.nameLabel2.lineBreakMode = NSLineBreakByTruncatingTail;
  74. }
  75. self.nameLabel2.frame = CGRectMake(60, 6, width, 21);
  76. self.sexImgView2.frame = CGRectMake(width+65, 9, 14, 14);
  77. self.rankImgView2.frame = CGRectMake(width+84, 8, 28, 16);
  78. self.nameLabel2.attributedText = attr;
  79. if ([model.sex isEqualToString:@"1"])
  80. {
  81. self.sexImgView2.image = [UIImage imageNamed:@"com_male_selected"];
  82. }else
  83. {
  84. self.sexImgView2.image = [UIImage imageNamed:@"com_female_selected"];
  85. }
  86. self.rankImgView2.image = [UIImage imageNamed:[NSString stringWithFormat:@"level%d",(int)model.user_level]];
  87. if (model.signature.length < 1)
  88. {
  89. self.commentLabel.text = @"";
  90. }else
  91. {
  92. self.commentLabel.lineBreakMode = NSLineBreakByTruncatingTail;
  93. NSMutableAttributedString *attr1 = [[NSMutableAttributedString alloc] initWithString:model.signature];
  94. self.commentLabel.attributedText = attr1;
  95. }
  96. }
  97. - (IBAction)clickAgreeBtn:(UIButton *)sender {
  98. //同意退出公会,做删除操作
  99. if (_delegate && [_delegate respondsToSelector:@selector(agreeQuitWithSocietyLeaveApplyCell:)]) {
  100. [_delegate agreeQuitWithSocietyLeaveApplyCell:self];
  101. }
  102. }
  103. - (IBAction)clickRefuseBtn:(UIButton *)sender {
  104. //拒绝退出公会,做删除操作
  105. if (_delegate && [_delegate respondsToSelector:@selector(refuseQuitWithSocietyLeaveApplyCell:)]) {
  106. [_delegate refuseQuitWithSocietyLeaveApplyCell:self];
  107. }
  108. }
  109. @end