Commit 0af7eb6dc9a54b23b374335534f597e6301c9724

Authored by 张旭
1 parent 334e7ba6

礼物选中效果

LiveVideoCloud/Classes/Sections/InteractionSections/Gift/GiftViews/GiftListView.m
... ... @@ -26,6 +26,7 @@
26 26 @property (nonatomic ,weak ) LiveBaseView * _Nullable liveBaseView;
27 27 @property (nonatomic, strong) AnimQueueManager * animQueueManager;
28 28 @property (nonatomic ,strong) GiftModel * _Nullable model;
  29 +@property (nonatomic ,strong) UIScrollView * _Nullable scrollView;
29 30 @property (nonatomic ,assign) BOOL isSelectedGift;
30 31 @property (nonatomic ,assign) NSInteger curruntSelectIdx;
31 32  
... ... @@ -53,6 +54,7 @@
53 54 scrollView.showsVerticalScrollIndicator = NO;
54 55 scrollView.showsHorizontalScrollIndicator = NO;
55 56 [self addSubview:scrollView];
  57 + self.scrollView = scrollView;
56 58  
57 59 int line = 0;
58 60 int row = 0;
... ... @@ -155,17 +157,40 @@
155 157 #pragma mark - 选择礼物点击
156 158 - (void)gestureClick:(UITapGestureRecognizer *)gesture
157 159 {
158   - _isSelectedGift = YES;
159 160 NSInteger tag = gesture.view.tag - 10;
160 161 NSLog(@"%zd",tag);
161 162  
162   -// if (_curruntSelectIdx == tag && _isSelectedGift) {
163   -// _isSelectedGift = NO;
164   -// _curruntSelectIdx = -1;
165   -// }
166   -// _curruntSelectIdx = tag;
167   -
168   - //右上角添加✔️,再次点击去掉✔️
  163 + if (_curruntSelectIdx == 0 && _isSelectedGift == NO) {//没选过
  164 + UIView *giftView = gesture.view;
  165 +
  166 + UIImageView *bgView = [[UIImageView alloc] initWithFrame:giftView.bounds];
  167 + bgView.backgroundColor = [UIColor blackColor];
  168 + bgView.tag = giftView.tag + 100;
  169 + bgView.alpha = 0.2;
  170 + [giftView addSubview:bgView];
  171 + }
  172 +
  173 + if (_curruntSelectIdx != 0 && _isSelectedGift == YES) {//选过
  174 + UIView *gView = gesture.view;
  175 + for (UIView *view in self.scrollView.subviews) {//移除上一个bgView
  176 + if (view.tag == _curruntSelectIdx) {
  177 + for (UIView *bg in view.subviews) {
  178 + if (bg.tag == view.tag + 100) {
  179 + [bg removeFromSuperview];
  180 + break;
  181 + }
  182 + }
  183 + }
  184 + }
  185 + //增加当前bgView
  186 + UIImageView *bgView = [[UIImageView alloc] initWithFrame:gView.bounds];
  187 + bgView.backgroundColor = [UIColor blackColor];
  188 + bgView.tag = gView.tag + 100;
  189 + bgView.alpha = 0.2;
  190 + [gView addSubview:bgView];
  191 + }
  192 + _isSelectedGift = YES;
  193 + _curruntSelectIdx = gesture.view.tag;
169 194  
170 195 GiftModel *model = self.giftArray[tag];
171 196 model.sender = [CNLiveChatManager sharedCNLiveChatManager].currentUserInfo.name;
... ...