TiUISubMenuTowViewCell.m 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // TiUISubMenuTowViewCell.m
  3. // TiSDKDemo
  4. //
  5. // Created by iMacA1002 on 2019/12/5.
  6. // Copyright © 2020 Tillusory Tech. All rights reserved.
  7. //
  8. #import "TiUISubMenuTowViewCell.h"
  9. #import "TIButton.h"
  10. @interface TiUISubMenuTowViewCell ()
  11. @property(nonatomic ,strong)TIButton *cellButton;
  12. @end
  13. @implementation TiUISubMenuTowViewCell
  14. -(TIButton *)cellButton{
  15. if (_cellButton==nil) {
  16. _cellButton = [[TIButton alloc]initWithScaling:0.95];
  17. _cellButton.userInteractionEnabled = NO;
  18. }
  19. return _cellButton;
  20. }
  21. - (instancetype)initWithFrame:(CGRect)frame
  22. {
  23. self = [super initWithFrame:frame];
  24. if (self) {
  25. [self addSubview:self.cellButton];
  26. }
  27. return self;
  28. }
  29. - (void)setSubMod:(TIMenuMode *)subMod{
  30. if (subMod) {
  31. _subMod = subMod;
  32. NSString *normalThumb = subMod.normalThumb?subMod.normalThumb:subMod.thumb;
  33. NSString *selectedThumb = subMod.selectedThumb?subMod.selectedThumb:subMod.thumb;
  34. [self.cellButton setTitle:[NSString stringWithFormat:@"%@",subMod.name]
  35. withImage:[UIImage imageNamed:normalThumb]
  36. withTextColor:TI_Color_Default_Text_Black
  37. forState:UIControlStateNormal];
  38. [self.cellButton setTitle:[NSString stringWithFormat:@"%@",subMod.name]
  39. withImage:[UIImage imageNamed:selectedThumb]
  40. withTextColor:TI_Color_Default_Background_Pink
  41. forState:UIControlStateSelected];
  42. [self.cellButton setSelected:subMod.selected];
  43. }
  44. }
  45. -(void)setCellType:(TiUISubMenuTowViewCellType)cellType{
  46. _cellType = cellType;
  47. switch (cellType) {
  48. case TI_UI_TOWSUBCELL_TYPE_ONE:
  49. {
  50. [self.cellButton setBorderWidth:0.0 BorderColor:[UIColor clearColor] forState:UIControlStateNormal];
  51. [self.cellButton setBorderWidth:2.0 BorderColor:TI_Color_Default_Background_Pink forState:UIControlStateSelected];
  52. [self.cellButton mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.top.bottom.left.right.equalTo(self);
  54. }];
  55. }
  56. break;
  57. case TI_UI_TOWSUBCELL_TYPE_TWO:
  58. {
  59. [self.cellButton mas_makeConstraints:^(MASConstraintMaker *make) {
  60. make.top.bottom.equalTo(self);
  61. make.left.equalTo(self.mas_left).offset(8);
  62. make.right.equalTo(self.mas_right).offset(-8);
  63. }];
  64. }
  65. break;
  66. default:
  67. break;
  68. }
  69. }
  70. @end