TiUISubMenuThreeViewCell.m 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. //
  2. // TiUISubMenuThreeViewCell.m
  3. // TiSDKDemo
  4. //
  5. // Created by iMacA1002 on 2019/12/6.
  6. // Copyright © 2020 Tillusory Tech. All rights reserved.
  7. //
  8. #import "TiUISubMenuThreeViewCell.h"
  9. #import "TIUITool.h"
  10. @interface TiUISubMenuThreeViewCell ()
  11. @property(nonatomic ,strong)TIButton *cellButton;
  12. @end
  13. @implementation TiUISubMenuThreeViewCell
  14. -(TIButton *)cellButton{
  15. if (_cellButton==nil) {
  16. _cellButton = [[TIButton alloc]initWithScaling:0.7];
  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. [self.cellButton mas_makeConstraints:^(MASConstraintMaker *make) {
  27. make.top.bottom.left.right.equalTo(self);
  28. }];
  29. [self.cellButton setBorderWidth:0.0 BorderColor:[UIColor whiteColor] forState:UIControlStateNormal];
  30. [self.cellButton setBorderWidth:2.0 BorderColor:TI_Color_Default_Background_Pink forState:UIControlStateSelected];
  31. }
  32. return self;
  33. }
  34. - (void)setSubMod:(TIMenuMode *)subMod WithTag:(NSInteger)tag
  35. {
  36. if (subMod) {
  37. _subMod = subMod;
  38. if (subMod.menuTag) {
  39. WeakSelf;
  40. NSString *iconUrl = @"";
  41. NSString *folder = @"";
  42. switch (tag) {
  43. case 2:
  44. iconUrl = [TiSDK getStickerIconURL];
  45. folder = @"sticker_icon";
  46. break;
  47. case 3:
  48. iconUrl = [TiSDK getGiftIconURL];
  49. folder = @"gift_icon";
  50. break;
  51. case 7:
  52. iconUrl = [TiSDK getWatermarkIconURL];
  53. folder = @"watermark_icon";
  54. break;
  55. case 8:
  56. iconUrl = [TiSDK getMaskIconURL];
  57. folder = @"mask_icon";
  58. break;
  59. case 9:
  60. iconUrl = [TiSDK getGreenScreenIconURL];
  61. folder = @"greenscreen_icon";
  62. break;
  63. default:
  64. break;
  65. }
  66. iconUrl = iconUrl?iconUrl:@"";
  67. [TIUITool getImageFromeURL:[NSString stringWithFormat:@"%@%@", iconUrl, subMod.thumb] WithFolder:folder downloadComplete:^(UIImage *image) {
  68. [weakSelf.cellButton setTitle:nil
  69. withImage:image
  70. withTextColor:nil
  71. forState:UIControlStateNormal];
  72. [weakSelf.cellButton setTitle:nil
  73. withImage:image
  74. withTextColor:nil
  75. forState:UIControlStateSelected];
  76. }];
  77. switch (subMod.downloaded) {
  78. case TI_DOWNLOAD_STATE_CCOMPLET://完成
  79. [self endAnimation];
  80. [self.cellButton setDownloaded:YES];
  81. break;
  82. case TI_DOWNLOAD_STATE_NOTBEGUN://未开始
  83. [self endAnimation];
  84. [self.cellButton setDownloaded:NO];
  85. break;
  86. case TI_DOWNLOAD_STATE_BEBEING://正在
  87. [self startAnimation];
  88. [self.cellButton setDownloaded:YES];
  89. break;
  90. default:
  91. break;
  92. }
  93. }else{
  94. [self.cellButton setTitle:nil
  95. withImage:[UIImage imageNamed:subMod.thumb]
  96. withTextColor:nil
  97. forState:UIControlStateNormal];
  98. [self.cellButton setTitle:nil
  99. withImage:[UIImage imageNamed:subMod.thumb]
  100. withTextColor:nil
  101. forState:UIControlStateSelected];
  102. [self endAnimation];
  103. [self.cellButton setDownloaded:YES];
  104. }
  105. [self.cellButton setSelected:subMod.selected];
  106. }
  107. }
  108. -(void)startAnimation{
  109. [self.cellButton startAnimation];
  110. }
  111. -(void)endAnimation{
  112. [self.cellButton endAnimation];
  113. }
  114. @end