CollectviewChooseCell.m 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //
  2. // CollectviewChooseCell.m
  3. // MuTableCollectMenu
  4. //
  5. // Created by Kingson on 2021/4/25.
  6. //
  7. #import "CollectviewChooseCell.h"
  8. #import <Masonry/Masonry.h>
  9. #define SelectNum_ItemHeight 51
  10. #define SelectNum_ItemWidth 77
  11. #define ItemFont1 17
  12. #define ItemFont2 16
  13. @implementation CollectviewChooseCell
  14. -(id)initWithFrame:(CGRect)frame
  15. {
  16. self = [super initWithFrame:frame];
  17. if (self) {
  18. [self initView];
  19. }
  20. return self;
  21. }
  22. -(void)initView{
  23. _SelectIconBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  24. _SelectIconBtn.userInteractionEnabled = NO;
  25. [_SelectIconBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
  26. [_SelectIconBtn setBackgroundImage:[UIImage imageNamed:@"collectview_Unselect"] forState:UIControlStateNormal];
  27. [_SelectIconBtn setBackgroundImage:[UIImage imageNamed:@"collectview_Selected"] forState:UIControlStateSelected];
  28. _SelectIconBtn.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
  29. [self.contentView addSubview:_SelectIconBtn];
  30. [_SelectIconBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  31. // make.left.equalTo(self.contentView.mas_left).offset(0);
  32. // make.right.equalTo(self.contentView.mas_right).offset(0);
  33. // make.top.equalTo(self.contentView.mas_top).offset(0);
  34. // make.bottom.equalTo(self.contentView.mas_bottom).offset(0);
  35. make.left.equalTo(self.mas_left);
  36. make.right.equalTo(self.mas_right);
  37. make.top.equalTo(self.mas_top);
  38. make.bottom.equalTo(self.mas_bottom);
  39. }];
  40. _titleLab = [[UILabel alloc]init];
  41. _titleLab.textColor = [UIColor darkTextColor];
  42. _titleLab.font = [UIFont systemFontOfSize:32];
  43. // _titleLab.textAlignment = NSTextAlignmentLeft;
  44. _titleLab.textAlignment = NSTextAlignmentCenter;
  45. _titleLab.lineBreakMode = NSLineBreakByWordWrapping;
  46. _titleLab.numberOfLines = 0;
  47. [self.contentView addSubview:_titleLab];
  48. [_titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.left.equalTo(self.mas_left);
  50. make.right.equalTo(self.mas_right);
  51. make.top.equalTo(self.mas_top);
  52. make.bottom.equalTo(self.mas_bottom);
  53. }];
  54. }
  55. -(void)UpdateCellWithState:(BOOL)select{
  56. self.SelectIconBtn.selected = select;
  57. _isSelected = select;
  58. }
  59. @end