SocietyListCell.m 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //
  2. // SocietyListCell.m
  3. // BuguLive
  4. //
  5. // Created by 王珂 on 17/1/22.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. //
  8. #import "SocietyListCell.h"
  9. #import "SocietyListModel.h"
  10. @interface SocietyListCell()
  11. @property (nonatomic, strong) UIImageView * headView; //公会头像
  12. @property (nonatomic, strong) UILabel * familyNameLabel; //公会名称
  13. @property (nonatomic, strong) UILabel * headerNameLabel; //公会会长名称
  14. @property (nonatomic, strong) UILabel * numberLabel1; //人数:
  15. @property (nonatomic, strong) UILabel * numberLabel2; //公会人数
  16. @property (nonatomic, strong) UILabel * numberLabel3; //人
  17. //@property (nonatomic, strong) UIButton * applyBtn; //加入公会
  18. @property (nonatomic, strong) UILabel * lineLabel; //画线
  19. @end
  20. @implementation SocietyListCell
  21. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  22. {
  23. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
  24. {
  25. _headView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 40, 40)];
  26. // _headView.backgroundColor = [UIColor redColor];
  27. _headView.layer.cornerRadius = 20;
  28. _headView.layer.masksToBounds = YES;
  29. [self.contentView addSubview:_headView];
  30. _familyNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 10, kScreenW-155, 18)];
  31. _familyNameLabel.font = [UIFont systemFontOfSize:15.0];
  32. [self.contentView addSubview:_familyNameLabel];
  33. _headerNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 32, 90, 18)];
  34. _headerNameLabel.font = [UIFont systemFontOfSize:13.0];
  35. _headerNameLabel.textColor = kAppGrayColor3;
  36. _headerNameLabel.text = ASLocalizedString(@"天使的眼泪");
  37. [self.contentView addSubview:_headerNameLabel];
  38. _numberLabel1 = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_headerNameLabel.frame)+10, 32, 40, 18)];
  39. _numberLabel1.textColor = kAppGrayColor3;
  40. _numberLabel1.text = ASLocalizedString(@"人数 :");
  41. _numberLabel1.font = [UIFont systemFontOfSize:13.0];
  42. [self.contentView addSubview:_numberLabel1];
  43. _numberLabel2 = [[UILabel alloc] init];
  44. _numberLabel2.textColor = kAppGrayColor1;
  45. _numberLabel2.font = [UIFont systemFontOfSize:13.0];
  46. [self.contentView addSubview:_numberLabel2];
  47. _numberLabel3 = [[UILabel alloc] init];
  48. _numberLabel3.textColor = kAppGrayColor3;
  49. _numberLabel3.font = [UIFont systemFontOfSize:13.0];
  50. [self.contentView addSubview:_numberLabel3];
  51. _applyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  52. _applyBtn.frame = CGRectMake(kScreenW-85, 15, 75, 30);
  53. _applyBtn.layer.cornerRadius = 12;
  54. _applyBtn.titleLabel.font = [UIFont systemFontOfSize:15.0];
  55. _applyBtn.layer.masksToBounds = YES;
  56. [self.contentView addSubview:_applyBtn];
  57. _lineLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 59, kScreenW-10, 0.5)];
  58. _lineLabel.backgroundColor = kAppGrayColor4;
  59. _lineLabel.alpha = 0.5;
  60. [self.contentView addSubview:_lineLabel];
  61. _numberLabel1.hidden = YES;
  62. _numberLabel2.hidden = YES;
  63. _numberLabel3.hidden = YES;
  64. }
  65. return self ;
  66. }
  67. - (void)setModel:(SocietyListModel *)model
  68. {
  69. _model = model;
  70. // [_headView sd_setImageWithURL:[NSURL URLWithString:model.family_logo]];
  71. [_headView sd_setImageWithURL:[NSURL URLWithString:model.logo] placeholderImage:kDefaultPreloadHeadImg];
  72. _familyNameLabel.text = model.name;
  73. _headerNameLabel.text = [NSString stringWithFormat:ASLocalizedString(@"会长 : %@"),model.nick_name];
  74. CGSize titleSize = [model.user_count boundingRectWithSize:CGSizeMake(kScreenW-290, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} context:nil].size;
  75. _numberLabel2.frame = CGRectMake(CGRectGetMaxX(_numberLabel1.frame), 32, titleSize.width, 18);
  76. _numberLabel2.text = model.user_count;
  77. _numberLabel3.frame = CGRectMake(CGRectGetMaxX(_numberLabel2.frame), 32, 13, 18);
  78. _numberLabel3.text = ASLocalizedString(@"人");
  79. if ([model.is_apply intValue]==1) {
  80. _applyBtn.backgroundColor = kAppGrayColor3;
  81. _applyBtn.enabled = NO;
  82. [_applyBtn setTitle:ASLocalizedString(@"申请中")forState:UIControlStateNormal];
  83. }
  84. else if ([model.is_apply intValue]==0)
  85. {
  86. _applyBtn.backgroundColor = kAppMainColor;
  87. _applyBtn.enabled = YES;
  88. [_applyBtn addTarget:self action:@selector(clickApplyBtn:) forControlEvents:UIControlEventTouchUpInside];
  89. [_applyBtn setTitle:ASLocalizedString(@"加入公会")forState:UIControlStateNormal];
  90. }
  91. else if ([model.is_apply intValue]==2)
  92. {
  93. _applyBtn.backgroundColor = kAppGrayColor3;
  94. _applyBtn.enabled = NO;
  95. [_applyBtn setTitle:ASLocalizedString(@"已加入")forState:UIControlStateNormal];
  96. }
  97. }
  98. - (void)clickApplyBtn:(UIButton *)applyBtn
  99. {
  100. if (_delegate && [_delegate respondsToSelector:@selector(applyWithSocietyListCell:)]) {
  101. [_delegate applyWithSocietyListCell:self];
  102. }
  103. }
  104. - (void)awakeFromNib
  105. {
  106. [super awakeFromNib];
  107. }
  108. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  109. [super setSelected:selected animated:animated];
  110. // Configure the view for the selected state
  111. }
  112. @end