JXWhoCanSeeCell.m 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //
  2. // JXWhoCanSeeCell.m
  3. // shiku_im
  4. //
  5. // Created by p on 2018/6/27.
  6. // Copyright © 2018年 Reese. All rights reserved.
  7. //
  8. #import "JXWhoCanSeeCell.h"
  9. @implementation JXWhoCanSeeCell
  10. - (void)awakeFromNib {
  11. [super awakeFromNib];
  12. // Initialization code
  13. }
  14. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  15. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  16. if (self) {
  17. self.selectionStyle = UITableViewCellSelectionStyleNone;
  18. [self customView];
  19. }
  20. return self;
  21. }
  22. - (void)customView {
  23. _contentBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
  24. [_contentBtn addTarget:self action:@selector(contentBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  25. [self.contentView addSubview:_contentBtn];
  26. _selImageView = [[UIImageView alloc] initWithFrame:CGRectMake(30, 20, 20, 20)];
  27. _selImageView.image = [UIImage imageNamed:@"sel_nor_wx2"];
  28. [self.contentView addSubview:_selImageView];
  29. _title = [[JXLabel alloc] initWithFrame:CGRectMake(60, 6, JX_SCREEN_WIDTH-60-30, 20)];
  30. _title.font = g_factory.font16;
  31. _title.backgroundColor = [UIColor clearColor];
  32. _title.textColor = [UIColor blackColor];
  33. [self.contentView addSubview:_title];
  34. _userNames = [[JXLabel alloc] initWithFrame:CGRectMake(60, CGRectGetMaxY(_title.frame)+6, JX_SCREEN_WIDTH-60-30, 17)];
  35. _userNames.font = g_factory.font15;
  36. _userNames.backgroundColor = [UIColor clearColor];
  37. _userNames.textColor = [UIColor grayColor];
  38. [self.contentView addSubview:_userNames];
  39. _editBtn = [[UIButton alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH - 40, 20, 20, 20)];
  40. [_editBtn setBackgroundImage:[UIImage imageNamed:@"icg"] forState:UIControlStateNormal];
  41. [_editBtn addTarget:self action:@selector(editBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  42. [self.contentView addSubview:_editBtn];
  43. }
  44. - (void)contentBtnAction:(UIButton *)btn {
  45. btn.selected = !btn.selected;
  46. if (btn.selected) {
  47. self.selImageView.image = [UIImage imageNamed:@"sel_check_wx2"];
  48. }else {
  49. self.selImageView.image = [UIImage imageNamed:@"sel_nor_wx2"];
  50. }
  51. if ([self.delegate respondsToSelector:@selector(whoCanSeeCell:selectAction:)]) {
  52. [self.delegate whoCanSeeCell:self selectAction:self.index];
  53. }
  54. }
  55. - (void)editBtnAction:(UIButton *)btn {
  56. if ([self.delegate respondsToSelector:@selector(whoCanSeeCell:editBtnAction:)]) {
  57. [self.delegate whoCanSeeCell:self editBtnAction:self.index];
  58. }
  59. }
  60. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  61. [super setSelected:selected animated:animated];
  62. // Configure the view for the selected state
  63. }
  64. @end