FamilyListViewCell.m 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. //
  2. // FamilyListViewCell.m
  3. // BuguLive
  4. //
  5. // Created by 王珂 on 16/9/26.
  6. // Copyright © 2016年 xfg. All rights reserved.
  7. //
  8. #import "FamilyListViewCell.h"
  9. #import "FamilyListModel.h"
  10. @interface FamilyListViewCell()
  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 FamilyListViewCell
  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. }
  62. return self ;
  63. }
  64. - (void)setModel:(FamilyListModel *)model
  65. {
  66. _model = model;
  67. // [_headView sd_setImageWithURL:[NSURL URLWithString:model.family_logo]];
  68. [_headView sd_setImageWithURL:[NSURL URLWithString:model.family_logo] placeholderImage:kDefaultPreloadHeadImg];
  69. _familyNameLabel.text = model.family_name;
  70. _headerNameLabel.text = [NSString stringWithFormat:ASLocalizedString(@"族长 : %@"),model.nick_name];
  71. CGSize titleSize = [model.user_count boundingRectWithSize:CGSizeMake(kScreenW-290, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} context:nil].size;
  72. _numberLabel2.frame = CGRectMake(CGRectGetMaxX(_numberLabel1.frame), 32, titleSize.width, 18);
  73. _numberLabel2.text = model.user_count;
  74. _numberLabel3.frame = CGRectMake(CGRectGetMaxX(_numberLabel2.frame), 32, 13, 18);
  75. _numberLabel3.text = ASLocalizedString(@"人");
  76. if ([model.is_apply intValue]==1) {
  77. _applyBtn.backgroundColor = kAppGrayColor3;
  78. _applyBtn.enabled = NO;
  79. [_applyBtn setTitle:ASLocalizedString(@"申请中")forState:UIControlStateNormal];
  80. }
  81. else if ([model.is_apply intValue]==0)
  82. {
  83. _applyBtn.backgroundColor = kAppMainColor;
  84. _applyBtn.enabled = YES;
  85. [_applyBtn addTarget:self action:@selector(clickApplyBtn:) forControlEvents:UIControlEventTouchUpInside];
  86. [_applyBtn setTitle:ASLocalizedString(@"加入公会")forState:UIControlStateNormal];
  87. }
  88. else if ([model.is_apply intValue]==2)
  89. {
  90. _applyBtn.backgroundColor = kAppGrayColor3;
  91. _applyBtn.enabled = NO;
  92. [_applyBtn setTitle:ASLocalizedString(@"已加入")forState:UIControlStateNormal];
  93. }
  94. }
  95. - (void)clickApplyBtn:(UIButton *)applyBtn
  96. {
  97. if (_delegate && [_delegate respondsToSelector:@selector(applyWithFamilyListViewCell:)]) {
  98. [_delegate applyWithFamilyListViewCell:self];
  99. }
  100. }
  101. - (void)awakeFromNib
  102. {
  103. [super awakeFromNib];
  104. }
  105. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  106. [super setSelected:selected animated:animated];
  107. // Configure the view for the selected state
  108. }
  109. @end