Commit 0af7eb6dc9a54b23b374335534f597e6301c9724
1 parent
334e7ba6
礼物选中效果
Showing
1 changed file
with
33 additions
and
8 deletions
LiveVideoCloud/Classes/Sections/InteractionSections/Gift/GiftViews/GiftListView.m
| @@ -26,6 +26,7 @@ | @@ -26,6 +26,7 @@ | ||
| 26 | @property (nonatomic ,weak ) LiveBaseView * _Nullable liveBaseView; | 26 | @property (nonatomic ,weak ) LiveBaseView * _Nullable liveBaseView; |
| 27 | @property (nonatomic, strong) AnimQueueManager * animQueueManager; | 27 | @property (nonatomic, strong) AnimQueueManager * animQueueManager; |
| 28 | @property (nonatomic ,strong) GiftModel * _Nullable model; | 28 | @property (nonatomic ,strong) GiftModel * _Nullable model; |
| 29 | +@property (nonatomic ,strong) UIScrollView * _Nullable scrollView; | ||
| 29 | @property (nonatomic ,assign) BOOL isSelectedGift; | 30 | @property (nonatomic ,assign) BOOL isSelectedGift; |
| 30 | @property (nonatomic ,assign) NSInteger curruntSelectIdx; | 31 | @property (nonatomic ,assign) NSInteger curruntSelectIdx; |
| 31 | 32 | ||
| @@ -53,6 +54,7 @@ | @@ -53,6 +54,7 @@ | ||
| 53 | scrollView.showsVerticalScrollIndicator = NO; | 54 | scrollView.showsVerticalScrollIndicator = NO; |
| 54 | scrollView.showsHorizontalScrollIndicator = NO; | 55 | scrollView.showsHorizontalScrollIndicator = NO; |
| 55 | [self addSubview:scrollView]; | 56 | [self addSubview:scrollView]; |
| 57 | + self.scrollView = scrollView; | ||
| 56 | 58 | ||
| 57 | int line = 0; | 59 | int line = 0; |
| 58 | int row = 0; | 60 | int row = 0; |
| @@ -155,17 +157,40 @@ | @@ -155,17 +157,40 @@ | ||
| 155 | #pragma mark - 选择礼物点击 | 157 | #pragma mark - 选择礼物点击 |
| 156 | - (void)gestureClick:(UITapGestureRecognizer *)gesture | 158 | - (void)gestureClick:(UITapGestureRecognizer *)gesture |
| 157 | { | 159 | { |
| 158 | - _isSelectedGift = YES; | ||
| 159 | NSInteger tag = gesture.view.tag - 10; | 160 | NSInteger tag = gesture.view.tag - 10; |
| 160 | NSLog(@"%zd",tag); | 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 | GiftModel *model = self.giftArray[tag]; | 195 | GiftModel *model = self.giftArray[tag]; |
| 171 | model.sender = [CNLiveChatManager sharedCNLiveChatManager].currentUserInfo.name; | 196 | model.sender = [CNLiveChatManager sharedCNLiveChatManager].currentUserInfo.name; |