123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- //
- // YOUPAILZAudienceMenuView.m
- // TIANYAN
- //
- // Created by CY on 2021/5/24.
- // Copyright © 2021 leo. All rights reserved.
- //
- #import "YOUPAILZAudienceMenuView.h"
- @interface YOUPAILZAudienceMenuView ()
- @property (nonatomic, strong) UIView *youpaipsupView;
- @property (nonatomic, weak) UIScrollView *youpaipscrollView;
- @property (nonatomic, strong) NSMutableArray <UIImageView *>* youpaipimgVs;
- @end
- @implementation YOUPAILZAudienceMenuView
- - (instancetype)initWithSupView:(UIView *)view{
- if (self = [super init]) {
- _youpaipsupView = view;
- self.frame = _youpaipsupView.bounds;
- self.hidden = YES;
- [self youpaifinitUI];
-
- [_youpaipsupView addSubview:self];
- }
- return self;
- }
- - (void)youpaifinitUI{
- UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, self.mj_h - 116.0f - SafeHeight, self.mj_w, 116.0f + SafeHeight)];
- scrollView.backgroundColor = HexColorFromRGB(0x2A2935);
- [LCTools clipCorner:UIRectCornerTopLeft|UIRectCornerTopRight View:scrollView size:CGSizeMake(20.0f, 20.0f)];
- scrollView.showsVerticalScrollIndicator = NO;
- scrollView.showsHorizontalScrollIndicator = NO;
- [self addSubview:scrollView];
- self.youpaipscrollView = scrollView;
-
- for (NSInteger i = 0; i < self.arr.count; i ++) {
-
- NSDictionary *dict = self.arr[i];
-
- UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
- CGFloat width = (self.mj_w - 4.0f) / self.arr.count;
- btn.frame = CGRectMake(2.0f + i * width, 28.0f, width, 60.0f);
- btn.tag = i;
- [btn addTarget:self action:@selector(youpaifbtnClick:) forControlEvents:UIControlEventTouchUpInside];
- [scrollView addSubview:btn];
-
- UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake((width - 42.0f) / 2.0f, 0, 42.0f, 42.0f)];
- imageV.image = dict[@"image"];
- [btn addSubview:imageV];
- [self.youpaipimgVs addObject:imageV];
-
- UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, imageV.mj_h + 5.0f, btn.mj_w, btn.mj_h - (imageV.mj_h + 5.0f))];
- lab.font = LCFont(10.0f);
- lab.textColor = HexColorFromRGB(0xAAAAAA);
- lab.textAlignment = NSTextAlignmentCenter;
- lab.text = dict[@"title"];
- [btn addSubview:lab];
- }
- }
- - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
- UITouch* touch = [touches anyObject];
- UIView* view = [touch view];
- if (view != self.youpaipscrollView) {
- [self youpaifhiddenAnimation];
- }
- }
- - (void)youpaifbtnClick:(UIButton *)sender{
- sender.selected = !sender.selected;
- NSDictionary *dict = self.arr[sender.tag];
- NSString *type = dict[@"type"];
- UIImage *image = sender.selected ? dict[@"selImage"] : dict[@"image"];
- UIImageView *imgV = self.youpaipimgVs[sender.tag];
- imgV.image = image;
- if ([type isEqual:@"remove_screen"]) {
- if (self.youpaiphideChatMessageBlock != nil) {
- self.youpaiphideChatMessageBlock();
- }
- }else if ([type isEqual:@"blacklist"]) {
- if (self.youpaipblocklistBlock != nil) {
- self.youpaipblocklistBlock();
- }
- }else if ([type isEqual:@"report"]) {
- if (self.youpaipreportBlock != nil) {
- self.youpaipreportBlock();
- }
- }else if ([type isEqual:@"voice"]) {
- if (self.youpaipcloseVoiceBlock != nil) {
- self.youpaipcloseVoiceBlock(sender.selected);
- }
- }else if ([type isEqual:@"anchor_close"]) {
- if (self.youpaipcloseBlock != nil) {
- self.youpaipcloseBlock();
- }
- }
- [self youpaifhiddenAnimation];
- }
- - (void)youpaifshowAnimation{
- self.hidden = NO;
- self.youpaipscrollView.frame = CGRectMake(0, self.mj_h, self.mj_w, 116.0f + SafeHeight);
- [UIView animateWithDuration:0.25f animations:^{
- self.youpaipscrollView.frame = CGRectMake(0, self.mj_h - 116.0f - SafeHeight, self.mj_w, 116.0f + SafeHeight);
- }];
- }
- - (void)youpaifhiddenAnimation{
- self.youpaipscrollView.frame = CGRectMake(0, self.mj_h - 116.0f - SafeHeight, self.mj_w, 116.0f + SafeHeight);
- [UIView animateWithDuration:0.25f animations:^{
- self.youpaipscrollView.frame = CGRectMake(0, self.mj_h, self.mj_w, 116.0f + SafeHeight);
- } completion:^(BOOL finished) {
- if (finished) {
- self.hidden = YES;
- }
- }];
- }
- - (NSMutableArray<UIImageView *> *)youpaipimgVs{
- if (!_youpaipimgVs) {
- _youpaipimgVs = [[NSMutableArray alloc] init];
- }
- return _youpaipimgVs;
- }
- - (NSArray *)arr{
- return @[
- @{@"title":@"清屏",@"image":[UIImage imageNamed:@"vqu_images_L_live_remove_screen"],@"selImage":[UIImage imageNamed:@"vqu_images_L_live_remove_screen"],@"type":@"remove_screen"},
- @{@"title":@"拉黑",@"image":[UIImage imageNamed:@"vqu_images_L_live_blacklist"],@"selImage":[UIImage imageNamed:@"vqu_images_L_live_blacklist"],@"type":@"blacklist"},
- @{@"title":@"举报",@"image":[UIImage imageNamed:@"vqu_images_L_live_report"],@"selImage":[UIImage imageNamed:@"vqu_images_L_live_report"],@"type":@"report"},
- @{@"title":@"静音",@"image":[UIImage imageNamed:@"vqu_images_L_live_voice"],@"selImage":[UIImage imageNamed:@"vqu_images_L_live_voice_close"],@"type":@"voice"},
- // @{@"title":@"结束",@"image":[UIImage imageNamed:@"vqu_images_L_live_anchor_close"],@"selImage":[UIImage imageNamed:@"vqu_images_L_live_anchor_close"],@"type":@"anchor_close"},
- ];
- }
- @end
|