// // YOUPAILZUserShowHeaderView.m // VQU // // Created by CY on 2021/7/10. // Copyright © 2021 leo. All rights reserved. // #import "YOUPAILZUserShowHeaderView.h" #import "SDCycleScrollView.h" #import "LCCommonHttp.h" #import "LOTAnimationView.h" #import "YYImage.h" #import "YOUPAILZLiveModel.h" #import "YOUPAILZLiveAudienceVC.h" #import "YOUPAILZEndLiveHintView.h" #import "YOUPAILZLevelView.h" #import "YOUPAIHRAgeSexView.h" #import "YOUPAILZChatRoomPasswordWindow.h" #import "YOUPAILZChatRoomVC.h" #import "UIViewController+TFPresent.h" #import "YOUPAIRightCollectionView.h" #import "YOUPAIShowHeaderBigImageCell.h" #import "ZFPlayerControlView.h" #import "ZFAVPlayerManager.h" #import "YOUPAIZFDouYinControlView.h" #import "YOUPAISexView.h" #import "YBIBVideoData.h" @interface YOUPAILZUserShowHeaderView () @property (nonatomic, strong)YOUPAILCUserShowModel *youpaipmodel; @property (nonatomic,weak) UIImageView *youpaipanimationImgV; @property (nonatomic, strong)NSArray *youpaipavatarUrls; /* avatarCountL */ @property (strong, nonatomic) UILabel *youpaipavatarCountL; @property (nonatomic,strong) UICollectionView * collectionView; @property (nonatomic,strong) UIButton * videoCoverImgV; @property(nonatomic,strong)YOUPAIRightCollectionView *rightCollectionView; @property (nonatomic, strong) ZFPlayerController *player; @property (nonatomic, strong) UIImageView *containerView; @property (nonatomic, strong) YOUPAIZFDouYinControlView *youpaipcontrolView; @property(nonatomic,strong)UIView *youpaipmemberAvatarBgV; @property(nonatomic,strong)NSMutableArray *youpaipmemberAvatars; @end @implementation YOUPAILZUserShowHeaderView - (instancetype)initWithModel:(YOUPAILCUserShowModel *)model{ if (self = [super init]) { _youpaipmodel = model; [self youpaifinitUI]; // [self youpaifinitAudioStream]; } return self; } - (void)youpaifinitUI{ UIView *infoBgV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth,458.0f+StatusBarHeight+20)]; [self addSubview:infoBgV]; UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init]; flowLayout.itemSize = CGSizeMake(KScreenWidth, 375); flowLayout.minimumInteritemSpacing = 0.0; flowLayout.minimumLineSpacing = 0.0; flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal; self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 375) collectionViewLayout:flowLayout]; self.collectionView.delegate = self; self.collectionView.backgroundColor = [UIColor whiteColor]; self.collectionView.pagingEnabled = YES; self.collectionView.showsVerticalScrollIndicator = NO; self.collectionView.showsHorizontalScrollIndicator = NO; self.collectionView.delegate = self; self.collectionView.dataSource = self; // self.collectionView.zf_scrollViewDirection = ZFPlayerScrollViewDirectionHorizontal; [infoBgV addSubview:self.collectionView]; //右下角小图片 YOUPAIRightCollectionView *rightCollectionView = [[YOUPAIRightCollectionView alloc]initWithFrame:CGRectMake(12, 302, KScreenWidth-12-96, 44)]; [infoBgV addSubview:rightCollectionView]; rightCollectionView.Model = self.youpaipmodel; self.rightCollectionView = rightCollectionView; @weakify(self) [rightCollectionView setDidSelectImageIndex:^(NSInteger index) { @strongify(self) [self didSelectImageIndex:index]; }]; UIView *titleView = [[UIView alloc] init]; [infoBgV addSubview:titleView]; [titleView mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(0); make.centerY.mas_equalTo(rightCollectionView).offset(10); make.size.mas_equalTo(CGSizeMake(90, 34)); }]; UIView *statusBgView = [[UIView alloc] init]; statusBgView.layer.cornerRadius = 8.81f; statusBgView.layer.masksToBounds = YES; statusBgView.backgroundColor = [HexColorFromRGB(0x1C1D23) colorWithAlphaComponent:0.38f]; [titleView addSubview:statusBgView]; [statusBgView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(titleView.mas_centerX); if (self.youpaipmodel.youpaipalbum.count == 0) { make.centerY.equalTo(titleView.mas_centerY); }else{ make.top.offset(8.0f); } make.size.mas_offset(CGSizeMake([LCTools widthWithString:self.youpaipmodel.youpaipAddnewMsg withFont:[UIFont systemFontOfSize:11]]+21, 17.62f)); }]; UIView *statusView = [[UIView alloc] init]; statusView.layer.cornerRadius = 3.0f; statusView.layer.masksToBounds = YES; [statusBgView addSubview:statusView]; [statusView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(statusBgView); make.left.offset(6.5f); make.size.mas_offset(CGSizeMake(6.0f, 6.0f)); }]; UILabel *statusL = [[UILabel alloc] init]; statusL.font = LCFont(11.0f); statusL.textColor = [UIColor whiteColor]; [statusBgView addSubview:statusL]; [statusL mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(statusBgView); make.left.equalTo(statusView.mas_right).offset(3.0f); }]; statusView.backgroundColor = kColors(self.youpaipmodel.youpaipAddnewColor); statusL.text = self.youpaipmodel.youpaipAddnewMsg; UIView *bgV = [[UIView alloc] initWithFrame:CGRectMake(0, 360, KScreenWidth, 142)]; [infoBgV addSubview:bgV]; //142 bgV.backgroundColor = [UIColor whiteColor]; [LCTools clipCorner:UIRectCornerTopLeft|UIRectCornerTopRight View:bgV size:CGSizeMake(16, 16)]; CGFloat width = 0; if (self.youpaipmodel.youpaipnickname.length>5) { NSString *str = [self.youpaipmodel.youpaipnickname substringToIndex:5]; width = [LCTools widthWithString:str withFont:LCBoldFont(18)]+5; }else{ width = [LCTools widthWithString:self.youpaipmodel.youpaipnickname withFont:LCBoldFont(18)]+5; } //姓名 UILabel *nicknameL = [[UILabel alloc] init]; nicknameL.textColor = LZ273145Color; nicknameL.text = self.youpaipmodel.youpaipnickname; [bgV addSubview:nicknameL]; [nicknameL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(12.0f); make.top.equalTo(12); }]; YOUPAISexView *sexView = [[YOUPAISexView alloc] init]; [bgV addSubview:sexView]; [sexView makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(nicknameL.mas_right).offset(@2); make.centerY.equalTo(nicknameL); make.size.mas_equalTo(CGSizeMake(30, 15)); }]; [sexView youpaifreloadWithSex:self.youpaipmodel.youpaipgender age:self.youpaipmodel.youpaipage]; //真人图标 UIImageView *personImageView = [UIImageView new]; [bgV addSubview:personImageView]; [personImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(sexView.mas_right).offset(@2); make.centerY.equalTo(sexView); make.size.mas_equalTo(CGSizeMake(37, 16)); }]; if (self.youpaipmodel.youpaipis_anchor ==1) { personImageView.image = [UIImage imageNamed:@"vqu_images_zhenrentag"]; } // //地址 // UILabel *cityL = [[UILabel alloc] init]; // cityL.font = LCFont12; // cityL.textColor = [UIColor whiteColor]; // cityL.text = self.youpaipmodel.youpaipinfo.youpaipcity; // [infoBgV addSubview:cityL]; // [cityL mas_makeConstraints:^(MASConstraintMaker *make) { // make.left.offset(48); // make.bottom.offset(-10.0f); // }]; // // UIView *line1 = [[UIView alloc] init]; // line1.backgroundColor = [UIColor whiteColor]; // [infoBgV addSubview:line1]; // [line1 mas_makeConstraints:^(MASConstraintMaker *make) { // make.left.equalTo(cityL.mas_right).offset(10.0f); // make.centerY.equalTo(cityL.mas_centerY); // make.size.mas_offset(CGSizeMake(0.5f, 7.0f)); // }]; // //粉丝 // UILabel *fansL = [[UILabel alloc] init]; // fansL.font = LCFont12; // fansL.textColor = [UIColor whiteColor]; // fansL.text = [NSString stringWithFormat:@"%@ 粉丝",@(self.youpaipmodel.youpaipinfo.youpaipfans_count)]; // [infoBgV addSubview:fansL]; // [fansL mas_makeConstraints:^(MASConstraintMaker *make) { // // make.left.equalTo(line1.mas_right).offset(10.0f); // make.centerY.equalTo(cityL.mas_centerY); // }]; // // UIView *line2 = [[UIView alloc] init]; // line2.backgroundColor = [UIColor whiteColor]; // [infoBgV addSubview:line2]; // [line2 mas_makeConstraints:^(MASConstraintMaker *make) { // make.left.equalTo(fansL.mas_right).offset(10.0f); // make.centerY.equalTo(fansL.mas_centerY); // make.size.mas_offset(CGSizeMake(0.5f, 7.0f)); // }]; // //复制 // UIButton *idBtn = [UIButton buttonWithType:UIButtonTypeCustom]; // idBtn.titleLabel.font = LCFont12; // [idBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; // [idBtn setTitle:[NSString stringWithFormat:@"花舞号:%@",self.youpaipmodel.youpaipinfo.youpaipusercode] forState:UIControlStateNormal]; // [idBtn addTarget:self action:@selector(youpaifcopyBtnClick) forControlEvents:UIControlEventTouchUpInside]; // [infoBgV addSubview:idBtn]; // [idBtn mas_makeConstraints:^(MASConstraintMaker *make) { // make.left.equalTo(line2.mas_right).offset(10.0f); // make.centerY.equalTo(fansL.mas_centerY); // make.height.offset(12.0f); // }]; // // UIButton *copyIDBtn = [UIButton buttonWithType:UIButtonTypeCustom]; // [copyIDBtn setImage:[UIImage imageNamed:@"vqu_images_ic_profile_copy_code"] forState:UIControlStateNormal]; // [copyIDBtn addTarget:self action:@selector(youpaifcopyBtnClick) forControlEvents:UIControlEventTouchUpInside]; // [infoBgV addSubview:copyIDBtn]; // [copyIDBtn mas_makeConstraints:^(MASConstraintMaker *make) { // make.left.equalTo(idBtn.mas_right).offset(4.0f); // make.centerY.equalTo(idBtn.mas_centerY); // make.size.mas_offset(CGSizeMake(12.0f, 12.0f)); // }]; // 贵族 UIImageView *vipImgV = [[UIImageView alloc] init]; [bgV addSubview:vipImgV]; // 勋章 UIImageView *badgeImgV = [[UIImageView alloc] init]; [bgV addSubview:badgeImgV]; // 等级 YOUPAILZLevelView *levelView = [[YOUPAILZLevelView alloc] init]; [bgV addSubview:levelView]; UIView *frontV; if (self.youpaipmodel.youpaipvip_icon.length != 0) { [vipImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipmodel.youpaipvip_icon]]; [vipImgV mas_makeConstraints:^(MASConstraintMaker *make) { if (frontV == nil) { make.left.equalTo(12); }else{ make.left.equalTo(frontV.mas_right).offset(3.0f); } make.top.equalTo(nicknameL.mas_bottom).offset(5); make.size.mas_offset(CGSizeMake(30.0f, 19.0f)); }]; frontV = vipImgV; } if (self.youpaipmodel.youpaipbadge_info.youpaipfile.length != 0) { [badgeImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipmodel.youpaipbadge_info.youpaipfile]]; [badgeImgV mas_remakeConstraints:^(MASConstraintMaker *make) { if (frontV == nil) { make.left.equalTo(12); }else{ make.left.equalTo(frontV.mas_right).offset(3.0f); } make.top.equalTo(nicknameL.mas_bottom).offset(5); make.size.mas_offset(CGSizeMake(self.youpaipmodel.youpaipbadge_info.youpaipwidth, 17.0f)); }]; frontV = badgeImgV; } [levelView youpaifreloadWithIcon:self.youpaipmodel.youpaipgr.youpaipgrade.youpaipimg1 iconWidth:self.youpaipmodel.youpaipgr.youpaipgrade.youpaipicon_width bgImg:self.youpaipmodel.youpaipgr.youpaipgrade.youpaipimg2 bgImgWidth:self.youpaipmodel.youpaipgr.youpaipgrade.youpaipicon1_width levelName:self.youpaipmodel.youpaipgr.youpaipgrade.youpaipgrade_name level:self.youpaipmodel.youpaipgr.youpaipgrade.youpaipgrade]; [levelView mas_remakeConstraints:^(MASConstraintMaker *make) { if (frontV == nil) { make.left.equalTo(12); }else{ make.left.equalTo(frontV.mas_right).offset(3.0f); } make.top.equalTo(nicknameL.mas_bottom).offset(5); make.size.mas_offset(levelView.mj_size); }]; //关注 UIButton *followBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [followBtn setImage:[UIImage imageNamed:@"vqu_images_ic_user_show_follow_new"] forState:UIControlStateNormal]; [followBtn addTarget:self action:@selector(youpaiffollowBtnClick:) forControlEvents:UIControlEventTouchUpInside]; followBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 6.0f, 0, 0); [bgV addSubview:followBtn]; [followBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.offset(-14.0f); make.top.equalTo(19); make.size.mas_offset(CGSizeMake(28.0f, 28.0f)); }]; // followBtn.hidden = [@(self.model.info.is_follow) boolValue]; [followBtn setImage:[UIImage imageNamed:@"vqu_images_ic_user_show_follow_new"] forState:(UIControlStateNormal)]; [followBtn setImage:[UIImage imageNamed:@"vqu_images_ic_user_show_follow_new_select"] forState:(UIControlStateSelected)]; if ([self.youpaipmodel.youpaipuserid isEqualToString:[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id]) { followBtn.hidden = YES; }else{ followBtn.hidden = NO; } followBtn.selected = self.youpaipmodel.youpaipis_follow == 1 ? YES : NO; //我的守护 UIView *guardBgView = [UIView new]; [bgV addSubview:guardBgView]; [guardBgView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(12); make.bottom.mas_equalTo(-20); make.size.mas_equalTo(CGSizeMake(KScreenWidth-85, 44)); }]; guardBgView.backgroundColor = HexColorFromRGBA(0x7C69FE, 0.1); guardBgView.layer.cornerRadius = 8; guardBgView.layer.masksToBounds = YES; //title UILabel *guardTitle = [UILabel new]; [guardBgView addSubview:guardTitle]; [guardTitle mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(12); make.centerY.mas_equalTo(0); }]; guardTitle.text = @"ta的守护团"; guardTitle.font = [UIFont systemFontOfSize:13]; guardTitle.textColor = LZ7C69FEColor; //arrow UIImageView *arrowImageView = [UIImageView new]; [guardBgView addSubview:arrowImageView]; [arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-12); make.centerY.mas_equalTo(0); make.size.mas_equalTo(CGSizeMake(10, 10.5)); }]; arrowImageView.image = [UIImage imageNamed:@"vqu_images_arrow_gurad"]; //3个头像 UIView *youpaipmemberAvatarBgV = [[UIView alloc] init]; [guardBgView addSubview:youpaipmemberAvatarBgV]; self.youpaipmemberAvatarBgV = youpaipmemberAvatarBgV; [youpaipmemberAvatarBgV mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(arrowImageView.mas_left).offset(-2); make.centerY.mas_equalTo(arrowImageView); make.width.offset(0.0f); make.height.offset(30.0f); }]; guardBgView.userInteractionEnabled = YES; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(youpaipmemberAvatarBgVClick)]; [guardBgView addGestureRecognizer:tap]; [self youpaifeditBtnCountWithCount:self.youpaipmodel.youpaipguard.youpaiplist.count > 3 ? 3 : self.youpaipmodel.youpaipguard.youpaiplist.count]; [self.youpaipmemberAvatarBgV updateConstraints:^(MASConstraintMaker *make) { make.width.offset(self.youpaipmemberAvatars.count * 30.0f - (self.youpaipmemberAvatars.count - 1.0f) * 4.0f); }]; if (self.youpaipmodel.youpaipguard.youpaiplist.count<=0) { //暂无守护 UILabel *guardNoLabel = [UILabel new]; [guardBgView addSubview:guardNoLabel]; [guardNoLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(arrowImageView.mas_left).offset(-2); make.centerY.mas_equalTo(arrowImageView); }]; guardNoLabel.text = @"暂无守护"; guardNoLabel.font = [UIFont systemFontOfSize:10]; guardNoLabel.textColor = LZA3AABEColor; } for (NSInteger i = 0; i < self.youpaipmemberAvatars.count; i ++) { UIImageView *imgV = self.youpaipmemberAvatars[i]; imgV.layer.cornerRadius = 15.0f; imgV.layer.masksToBounds = YES; imgV.frame = CGRectMake(i * 30.0f - i * 4.0f, 0.0f, 30.0f, 30.0f); NSString *url = [NSString stringWithFormat:@"%@/%@",[LCSaveData getImageUrl]?[LCSaveData getImageUrl]:BaseImgUrl,self.youpaipmodel.youpaipguard.youpaiplist[i]]; [imgV sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:nil];; } //守护按钮 UIButton *guardBtn = [UIButton new]; [bgV addSubview:guardBtn]; [guardBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-12); make.centerY.mas_equalTo(guardBgView); make.size.mas_equalTo(CGSizeMake(47, 45)); }]; [guardBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_zhuye_guard"] forState:UIControlStateNormal]; [guardBtn addTarget:self action:@selector(guardBtnClick) forControlEvents:UIControlEventTouchUpInside]; // if (self.youpaipmodel.youpaipinfo.youpaipvoice_status == 1) { // UIView *aBgV = [[UIView alloc] init]; // aBgV.layer.cornerRadius = 13.5f; // aBgV.clipsToBounds = YES; // aBgV.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.88f]; // [infoBgV addSubview:aBgV]; // [aBgV mas_makeConstraints:^(MASConstraintMaker *make) { // make.left.offset(14.0f); // make.bottom.equalTo(nicknameL.mas_top).offset(-14.0f); // make.size.mas_offset(CGSizeMake(73.0f, 27.0f)); // }]; //// UITapGestureRecognizer * tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(youpaifplayAudioEvent:)]; //// [aBgV addGestureRecognizer:tapGesture]; // // UIButton *audioPlayBtn = [UIButton buttonWithType:UIButtonTypeCustom]; // [audioPlayBtn setImage:[UIImage imageNamed:@"vqu_images_ic_user_show_audio_none"] forState:UIControlStateSelected]; // [audioPlayBtn setImage:[UIImage imageNamed:@"vqu_images_ic_user_show_audio_play"] forState:UIControlStateNormal]; // audioPlayBtn.userInteractionEnabled = NO; // [aBgV addSubview:audioPlayBtn]; //// self.youpaipaudioPlayBtn = audioPlayBtn; // [audioPlayBtn mas_makeConstraints:^(MASConstraintMaker *make) { // make.left.offset(5.0f); // make.centerY.equalTo(aBgV.mas_centerY); // make.size.mas_offset(CGSizeMake(19.0f, 19.0f)); // }]; // // UILabel *timerL = [[UILabel alloc] init]; // timerL.font = LCFont(12); // timerL.textColor = HexColorFromRGB(0x666666); // timerL.text = [NSString stringWithFormat:@"%@\"",@(self.youpaipmodel.youpaipinfo.youpaipvoice_time)]; // [aBgV addSubview:timerL]; //// self.youpaiptimerL = timerL; // [timerL mas_makeConstraints:^(MASConstraintMaker *make) { // make.left.equalTo(audioPlayBtn.mas_right).offset(5.0f); // make.centerY.equalTo(aBgV); // }]; // // UIImageView *animationImgV = [[UIImageView alloc] init]; // animationImgV.image = [UIImage imageNamed:@"vqu_images_ic_user_show_audio_animation_3"]; // // NSMutableArray * animationArray = [NSMutableArray array]; // // for (NSInteger i = 0; i < 3; i ++) { // [animationArray addObject:[UIImage imageNamed:[NSString stringWithFormat:@"vqu_images_ic_user_show_audio_animation_%@",@(i + 1)]]]; // } // //设置动画数组 // [animationImgV setAnimationImages:animationArray]; // //设置动画播放次数 // [animationImgV setAnimationRepeatCount:INT32_MAX]; // //设置动画播放时间 // [animationImgV setAnimationDuration:3*0.35]; // // [aBgV addSubview:animationImgV]; // self.youpaipanimationImgV = animationImgV; // [animationImgV mas_makeConstraints:^(MASConstraintMaker *make) { // make.left.equalTo(timerL.mas_right).offset(5.0f); // make.centerY.equalTo(aBgV); // make.size.mas_offset(CGSizeMake(19.0f, 19.0f)); // }]; // } CGFloat totalHeight = 458+StatusBarHeight; // CGFloat bottom = 0; // NSString *content = self.youpaipmodel.youpaipinfo.youpaipsign; // if (content.length != 0) { // UILabel *signL = [[UILabel alloc] init]; // // signL.text = @"说一段话介绍自己,或唱一首歌!"; // signL.font = LCFont12; // signL.textColor = [UIColor whiteColor]; // signL.numberOfLines = 0; //// signL.text = content; // [self addSubview:signL]; // [signL mas_makeConstraints:^(MASConstraintMaker *make) { // make.left.offset(14.0f); // make.top.equalTo(infoBgV.mas_bottom).offset(10.0f); // make.right.offset(-14.0f); //// make.bottom.offset(-25.0f); // }]; // // NSMutableAttributedString * attributedString1 = [[NSMutableAttributedString alloc] initWithString:content]; // NSMutableParagraphStyle * paragraphStyle1 = [[NSMutableParagraphStyle alloc] init]; // paragraphStyle1.alignment=NSTextAlignmentJustified; // NSDictionary * dic =@{ // NSParagraphStyleAttributeName:paragraphStyle1, // NSUnderlineStyleAttributeName:[NSNumber numberWithInteger:NSUnderlineStyleNone], // }; // [attributedString1 setAttributes:dic range:NSMakeRange(0, attributedString1.length)]; // [signL setAttributedText:attributedString1]; // // CGFloat height = [content boundingRectWithSize:CGSizeMake(KScreenWidth - 28.0f, MAXFLOAT) // options:NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin // attributes:@{ NSFontAttributeName : LCFont12 } context:nil].size.height; // // totalHeight += height + 35.0f; // bottom+=height+35; // } //页码 // if (self.youpaipmodel.youpaipalbum.count != 0) { // UILabel *avatarCountL = [[UILabel alloc] init]; // avatarCountL.font = LCFont(9.0f); // avatarCountL.textColor = [UIColor whiteColor]; // avatarCountL.text = [NSString stringWithFormat:@"%@/%@",@(1),@(self.youpaipmodel.youpaipalbum.count)]; // [self addSubview:avatarCountL]; // self.youpaipavatarCountL = avatarCountL; // [avatarCountL mas_makeConstraints:^(MASConstraintMaker *make) { // make.right.equalTo(-14); // make.centerY.equalTo(idBtn.mas_centerY); // }]; // } // //直播中 // UIButton *leftTopBtn = [UIButton buttonWithType:UIButtonTypeCustom]; // // leftTopBtn.frame = CGRectMake(0, NavBarHeight, 94.0f, 27.0f); // UIImage *bgImage = [LCTools ColorImage:leftTopBtn.mj_size FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:GradientLeftToRight]; // [leftTopBtn setBackgroundImage:bgImage forState:UIControlStateNormal]; // [leftTopBtn setBackgroundImage:bgImage forState:UIControlStateHighlighted]; //// [LCTools clipCorner:UIRectCornerBottomRight View:leftTopBtn size:CGSizeMake(8.0f, 8.0f)]; // leftTopBtn.layer.cornerRadius = 15; // leftTopBtn.layer.masksToBounds = YES; // [self addSubview:leftTopBtn]; // [leftTopBtn mas_makeConstraints:^(MASConstraintMaker *make) { // make.bottom.mas_equalTo(-(bottom+35)); // make.right.mas_equalTo(-14.0f); // make.size.mas_equalTo(CGSizeMake(94.0f, 27.0f)); // }]; // [leftTopBtn addTarget:self action:@selector(leftTopBtnClick) forControlEvents:UIControlEventTouchUpInside]; //// NSString *path = [[NSBundle mainBundle] pathForResource:@"ic_live_zhibozhong_28" ofType:@"gif"]; //// YYAnimatedImageView *iconImgV = [[YYAnimatedImageView alloc] init]; //// iconImgV.image = [YYImage imageWithData:[NSData dataWithContentsOfFile:path]]; // // LOTAnimationView *iconImgV = [LOTAnimationView animationWithFilePath:[[NSBundle mainBundle] pathForResource:@"ic_chatroom_part" ofType:@"json"]]; // [leftTopBtn addSubview:iconImgV]; //// talkingAnimationView.frame = CGRectMake(0.0f, 0.0f, self.mj_w * 1.7f, self.mj_h * 1.7f); // iconImgV.loopAnimation = YES; // iconImgV.contentMode = UIViewContentModeScaleAspectFill; // [iconImgV play]; // [iconImgV mas_makeConstraints:^(MASConstraintMaker *make) { // make.left.offset(8.0f); // make.centerY.equalTo(leftTopBtn.mas_centerY); // make.size.mas_offset(CGSizeMake(16.0f, 14.0f)); // }]; // //// [leftTopBtn addSubview:iconImgV]; //// [iconImgV mas_makeConstraints:^(MASConstraintMaker *make) { //// make.left.offset(3.0f); //// make.centerY.equalTo(leftTopBtn.mas_centerY); //// make.size.mas_offset(CGSizeMake(12.5f, 12.5f)); //// }]; // // UIImageView *arrowImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_D_profile_item_arrow_w"]]; // [leftTopBtn addSubview:arrowImgV]; // [arrowImgV mas_makeConstraints:^(MASConstraintMaker *make) { // make.right.offset(-8.0f); // make.centerY.equalTo(leftTopBtn.mas_centerY); // make.size.mas_offset(CGSizeMake(8.0f, 8.0f)); // }]; // // UILabel *textL = [[UILabel alloc] init]; // textL.font = LCFont(11.0f); // textL.textColor = [UIColor whiteColor]; // textL.text = @"正在房间"; // [leftTopBtn addSubview:textL]; // [textL mas_makeConstraints:^(MASConstraintMaker *make) { // make.left.equalTo(iconImgV.mas_right).offset(3.0f); // make.right.equalTo(arrowImgV.mas_left).offset(-3.0f); // make.centerY.equalTo(leftTopBtn.mas_centerY); // }]; // leftTopBtn.hidden = NO; // if (self.youpaipmodel.youpaiptalk_room_id != 0) { // leftTopBtn.hidden = NO; // }else{ // leftTopBtn.hidden = YES; // } // UIView *bgv = [UIView new]; // [infoBgV addSubview:bgv]; // [bgv mas_makeConstraints:^(MASConstraintMaker *make) { // make.edges.mas_equalTo(0); // }]; // bgv.backgroundColor = [UIColor redColor]; self.frame = CGRectMake(0, 0, KScreenWidth, totalHeight); } #pragma mark /** 返回区数 @param collectionView 集合视图 @return 返回区数 */ - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { return 1; } /** 返回项目数 @param collectionView 集合视图 @param section 区 @return 项目数 */ - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return self.youpaipmodel.youpaipalbums.count; } -(UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ NSString *identifier=[NSString stringWithFormat:@"%ld%ld",(long)indexPath.section,(long)indexPath.row]; [self.collectionView registerClass:[YOUPAIShowHeaderBigImageCell class] forCellWithReuseIdentifier:identifier]; YOUPAIAlbumModel *model = self.youpaipmodel.youpaipalbums[indexPath.item]; YOUPAIShowHeaderBigImageCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath]; NSString *url = model.youpaipurl; if (indexPath.item == 0&&model.youpaipis_video == 1) {//视频 [self setupPlayer:cell.youpaipiconImageView:model.youpaipurl]; // [cell.youpaipiconImageView sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:nil]; }else{ [cell.youpaipiconImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/%@",[LCSaveData getImageUrl]?[LCSaveData getImageUrl]:BaseImgUrl,url]] placeholderImage:nil]; } return cell; } -(void)setupPlayer:(UIImageView*)imageView:(NSString*)url{ ZFAVPlayerManager *playerManager = [[ZFAVPlayerManager alloc] init]; playerManager.shouldAutoPlay = YES; /// 播放器相关 self.player = [ZFPlayerController playerWithPlayerManager:playerManager containerView:imageView]; self.player.controlView = self.youpaipcontrolView; self.player.disablePanMovingDirection = ZFPlayerDisablePanMovingDirectionAll; /// 设置退到后台继续播放 self.player.pauseWhenAppResignActive = NO; self.player.allowOrentitaionRotation = NO; @weakify(self) /// 播放完成 self.player.playerDidToEnd = ^(id _Nonnull asset) { @strongify(self) [self.player.currentPlayerManager replay]; }; self.player.assetURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@/%@",[LCSaveData getImageUrl]?[LCSaveData getImageUrl]:BaseImgUrl,url]]; [self.player playTheIndex:0]; [self.player.currentPlayerManager setMuted:YES]; } -(void)scrollViewDidScroll:(UIScrollView *)scrollView{ NSInteger current = scrollView.contentOffset.x / KScreenWidth; NSLog(@"下标===========%ld",(long)current); if (current == 0) { [self.player.currentPlayerManager play]; }else{ [self.player.currentPlayerManager pause]; } } -(void)didSelectImageIndex:(NSInteger)index{ [self.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:index inSection:0] atScrollPosition:UICollectionViewScrollPositionTop animated:YES]; } - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { NSInteger index = scrollView.contentOffset.x/KScreenWidth; [self.rightCollectionView setScrollToItemAtIndex:index]; [scrollView zf_scrollViewDidEndDecelerating]; } -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ NSMutableArray *tempArr = [NSMutableArray array]; for (int i=0; i= self.youpaipmemberAvatars.count) { [self youpaifaddBtnWithCount:count - self.youpaipmemberAvatars.count]; }else{ [self youpaifdeleteBtnWithCount:self.youpaipmemberAvatars.count - count]; } } - (void)youpaifdeleteBtnWithCount:(NSInteger)count{ if (count != 0) { for (NSInteger i = 0; i < count; i ++) { UIImageView *btn = self.youpaipmemberAvatars.lastObject; [self.youpaipmemberAvatars removeLastObject]; [btn removeFromSuperview]; } } } - (void)youpaifaddBtnWithCount:(NSInteger)count{ for (NSInteger i = 0; i < count; i ++) { [self youpaifcreateBtn]; } } - (void)youpaifcreateBtn{ UIImageView *imgV = [[UIImageView alloc] init]; imgV.contentMode = UIViewContentModeScaleAspectFill; [self.youpaipmemberAvatarBgV addSubview:imgV]; [self.youpaipmemberAvatars addObject:imgV]; } - (NSMutableArray *)youpaipmemberAvatars{ if (_youpaipmemberAvatars == nil) { _youpaipmemberAvatars = [NSMutableArray array]; } return _youpaipmemberAvatars; } @end