JXGroupHelperCell.m 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // JXGroupHelperCell.m
  3. // shiku_im
  4. //
  5. // Created by 1 on 2019/5/29.
  6. // Copyright © 2019年 Reese. All rights reserved.
  7. //
  8. #import "JXGroupHelperCell.h"
  9. @implementation JXGroupHelperCell
  10. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  11. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  12. UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(15, 7, 50, 50)];
  13. imageView.layer.cornerRadius = 50 / 2;
  14. imageView.layer.masksToBounds = YES;
  15. [self.contentView addSubview:imageView];
  16. _imageV = imageView;
  17. UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(imageView.frame) + 10, 10, JX_SCREEN_WIDTH - 65 - (CGRectGetMaxX(imageView.frame) + 10) - 10, 20)];
  18. title.font = [UIFont systemFontOfSize:16.0];
  19. [self.contentView addSubview:title];
  20. _title = title;
  21. UILabel *subTitle = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(imageView.frame) + 10, CGRectGetMaxY(title.frame) + 7, JX_SCREEN_WIDTH - 65 - (CGRectGetMaxX(imageView.frame) + 10) - 10, 20)];
  22. subTitle.font = [UIFont systemFontOfSize:14.0];
  23. subTitle.textColor = [UIColor lightGrayColor];
  24. [self.contentView addSubview:subTitle];
  25. _subTitle = subTitle;
  26. UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH - 65, 20, 50, 24)];
  27. btn.backgroundColor = THEMECOLOR;
  28. [btn setTitle:Localized(@"JX_Add") forState:UIControlStateNormal];
  29. [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  30. btn.titleLabel.font = [UIFont systemFontOfSize:15.0];
  31. btn.layer.cornerRadius = 3.0;
  32. btn.layer.masksToBounds = YES;
  33. btn.tag = self.tag;
  34. [btn addTarget:self action:@selector(onAdd:) forControlEvents:UIControlEventTouchUpInside];
  35. [self.contentView addSubview:btn];
  36. _addBtn = btn;
  37. }
  38. return self;
  39. }
  40. - (void)setDataWithModel:(JXHelperModel *)model {
  41. [_imageV sd_setImageWithURL:[NSURL URLWithString:model.iconUrl] placeholderImage:[UIImage imageNamed:@"avatar_normal"]];
  42. _title.text = model.name;
  43. _subTitle.text = model.desc;
  44. _addBtn.hidden = [_groupHelperArr containsObject:model.helperId];
  45. }
  46. - (void)onAdd:(UIButton *)button {
  47. if (self.delegate && [self.delegate respondsToSelector:@selector(groupHelperCell:clickAddBtnWithIndex:)]) {
  48. [self.delegate groupHelperCell:self clickAddBtnWithIndex:self.tag];
  49. }
  50. }
  51. @end