123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358 |
- //
- // YOUPAILZEndLiveHintView.m
- // VQU
- //
- // Created by 肖浩然的mac on 2021/7/27.
- // Copyright © 2021 leo. All rights reserved.
- //
- #import "YOUPAILZEndLiveHintView.h"
- #import "YYAnimatedImageView.h"
- #import "YYImage.h"
- #import "YOUPAILZLiveCloseModel.h"
- #import "YOUPAILZLiveModel.h"
- #import "YOUPAILZLiveAudienceVC.h"
- @interface YOUPAILZEndLiveHintView ()
- @property (nonatomic, strong) YOUPAILZLiveCloseModel *youpaipcloseModelmodel;
- @property (nonatomic, strong) YOUPAILZEndLiveHintModel *youpaipmodel;
- @property (nonatomic, weak) UIButton *youpaipfollowBtn; // 关注按钮
- @property (nonatomic, weak) UIView *youpaiprecommendBgV; // 推荐背景View
- @property(nonatomic,strong)UIButton *transformBtn;//换一批
- @property(nonatomic,strong)UILabel *youpaiprecommendL;//换一批
- @end
- @implementation YOUPAILZEndLiveHintView
- - (instancetype)initWithFrame:(CGRect)frame Model:(YOUPAILZEndLiveHintModel *)model{
- if (self = [super initWithFrame:CGRectZero]) {
- _youpaipmodel = model;
- [self youpaifsetSubView];
- }
- return self;
- }
- - (void)youpaifsetSubView {
-
- self.frame = CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight);
- [[UIApplication sharedApplication].keyWindow addSubview:self];
-
- // [UIView animateWithDuration:0.25 animations:^{
- self.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
- // }];
-
- [self youpaifinitUI];
- [self youpaiftransformBtnClick];
- }
- - (void)youpaifinitUI{
-
-
- UIImageView *bgV = [[UIImageView alloc] initWithFrame:self.bounds];
- bgV.contentMode = UIViewContentModeScaleAspectFill;
- bgV.userInteractionEnabled = YES;
- bgV.clipsToBounds = YES;
- [bgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipmodel.youpaipavatar]];
- [self addSubview:bgV];
-
- UIBlurEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
- UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:effect];
- effectView.frame = bgV.bounds;
- [bgV addSubview:effectView];
-
-
- UIImageView *youpaipavatarImgV = [[UIImageView alloc] init];
- youpaipavatarImgV.contentMode = UIViewContentModeScaleAspectFill;
- youpaipavatarImgV.layer.cornerRadius = 50.0f;
- youpaipavatarImgV.clipsToBounds = YES;
- [youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipmodel.youpaipavatar]];
- [bgV addSubview:youpaipavatarImgV];
- [youpaipavatarImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.mas_equalTo(0);
- make.top.equalTo(50+NavBarHeight);
- make.size.mas_offset(CGSizeMake(100.0f, 100.0f));
- }];
-
- UILabel *youpaipnicknameL = [[UILabel alloc] init];
-
- [bgV addSubview:youpaipnicknameL];
- [youpaipnicknameL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(youpaipavatarImgV.mas_bottom).offset(14.0f);
- make.centerX.mas_equalTo(0);
- make.height.mas_equalTo(16);
- }];
- youpaipnicknameL.font = LCFont16;
- youpaipnicknameL.textColor = HexColorFromRGB(0xffffff);
- youpaipnicknameL.text = self.youpaipmodel.youpaipnickname;
-
- UILabel *titleL = [[UILabel alloc] init];
- [bgV addSubview:titleL];
- [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(youpaipnicknameL.mas_bottom).offset(26);
- make.centerX.mas_equalTo(0);
- make.height.mas_equalTo(19);
- }];
-
- titleL.font = [UIFont systemFontOfSize:19];
- titleL.textColor = HexColorFromRGB(0xffffff);
- titleL.text = @"你来晚了,直播已结束啦~";
- UILabel *youpaiprecommendL = [[UILabel alloc] init];
- self.youpaiprecommendL = youpaiprecommendL;
- [bgV addSubview:youpaiprecommendL];
- [youpaiprecommendL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(titleL.mas_bottom).offset(48.0f);
- make.centerX.mas_equalTo(bgV.mas_centerX);
- make.height.mas_equalTo(12);
- }];
- youpaiprecommendL.font = LCFont12;
- youpaiprecommendL.textColor = HexColorFromRGB(0x9F9DA5);
- youpaiprecommendL.text = @"-------- 为您推荐,在线直播 --------";
-
- UIView *youpaiprecommendBgV = [[UIView alloc] init];
- [bgV addSubview:youpaiprecommendBgV];
- self.youpaiprecommendBgV = youpaiprecommendBgV;
-
- [youpaiprecommendBgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(bgV.mas_centerX);
- make.top.equalTo(youpaiprecommendL.mas_bottom).offset(25.0f);
- make.height.offset((KScreenWidth - 102.0f) / 3.0f);
- }];
-
-
- UIButton *transformBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- self.transformBtn = transformBtn;
- transformBtn.titleLabel.font = LCFont12;
- transformBtn.layer.cornerRadius = 13.0f;
- transformBtn.clipsToBounds = YES;
- [transformBtn setTitle:@"换一批" forState:0];
- [transformBtn addTarget:self action:@selector(youpaiftransformBtnClick) forControlEvents:UIControlEventTouchUpInside];
- [transformBtn setTitleColor:HexColorFromRGB(0xffffff) forState:UIControlStateNormal];
- transformBtn.layer.borderColor = HexColorFromRGB(0xffffff).CGColor;
- transformBtn.layer.borderWidth = 0.5f;
- [bgV addSubview:transformBtn];
- [transformBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(bgV.mas_centerX);
- make.top.equalTo(youpaiprecommendBgV.mas_bottom).offset(20.0f);
- make.size.mas_offset(CGSizeMake(69.0f, 26.0f));
- }];
- transformBtn.hidden = YES;
- [self youpaifcreateRecommendBtn];
- //退出
- UIButton *youpaipcloseBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [youpaipcloseBtn addTarget:self action:@selector(youpaifcloseBtnClick) forControlEvents:UIControlEventTouchUpInside];
- [bgV addSubview:youpaipcloseBtn];
- [youpaipcloseBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.offset(-75.0f - SafeHeight);
- make.size.mas_offset(CGSizeMake(KScreenWidth - 120.0f, 48));
- make.centerX.mas_equalTo(0);
- }];
- youpaipcloseBtn.layer.cornerRadius = 48/2;
- youpaipcloseBtn.layer.masksToBounds = YES;
- [youpaipcloseBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(KScreenWidth - 120.0f, 48) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:1] forState:UIControlStateNormal];
- [youpaipcloseBtn setTitle:@"退出" forState:UIControlStateNormal];
- [youpaipcloseBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- }
- - (void)youpaifcreateRecommendBtn{
- for (UIView *view in self.youpaiprecommendBgV.subviews) {
- [view removeFromSuperview];
- }
- CGFloat width = (KScreenWidth - 102.0f) / 3.0f;
- if (self.youpaipcloseModelmodel.youpaiplive.count<=0) {
- self.youpaiprecommendL.hidden = YES;
- self.transformBtn.hidden = YES;
- }else{
- self.youpaiprecommendL.hidden = NO;
- self.transformBtn.hidden = NO;
- }
- for (NSInteger i = 0; i < self.youpaipcloseModelmodel.youpaiplive.count; i ++) {
- YOUPAILZLiveListItemModel *itemModel = self.youpaipcloseModelmodel.youpaiplive[i];
- UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
- btn.imageView.contentMode = UIViewContentModeScaleAspectFill;
- btn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentFill;
- btn.contentVerticalAlignment = UIControlContentVerticalAlignmentFill;
- btn.layer.cornerRadius = 8.0f;
- btn.clipsToBounds = YES;
- btn.contentMode = UIViewContentModeScaleAspectFill;
- [btn sd_setImageWithURL:[LCTools getImageUrlWithAddress:itemModel.youpaipcover_img] forState:UIControlStateNormal];
- btn.tag = i;
- [btn addTarget:self action:@selector(youpaifitemClick:) forControlEvents:UIControlEventTouchUpInside];
- [self.youpaiprecommendBgV addSubview:btn];
-
- [btn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(i * width + i * 4.0f);
- make.top.bottom.offset(0.0f);
- make.width.offset(width);
- if (i == self.youpaipcloseModelmodel.youpaiplive.count - 1) {
- make.right.offset(0.0f);
- }
- }];
-
- UIButton *youpaipleftTopBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- youpaipleftTopBtn.userInteractionEnabled = NO;
- youpaipleftTopBtn.frame = CGRectMake(0, 0, 41.0f, 14.0f);
- UIImage *bgImage = [LCTools ColorImage:youpaipleftTopBtn.mj_size FromColors:@[HexColorFromRGB(0xFF2ADD),HexColorFromRGB(0xFF6769)] ByGradientType:GradientLeftToRight];
- [youpaipleftTopBtn setBackgroundImage:bgImage forState:UIControlStateNormal];
- [youpaipleftTopBtn setBackgroundImage:bgImage forState:UIControlStateHighlighted];
- [LCTools clipCorner:UIRectCornerBottomRight View:youpaipleftTopBtn size:CGSizeMake(8.0f, 8.0f)];
- youpaipleftTopBtn.userInteractionEnabled = NO;
- [btn addSubview:youpaipleftTopBtn];
- [youpaipleftTopBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.left.offset(0.0f);
- make.size.mas_offset(CGSizeMake(41.0f, 14.0f));
- }];
-
- NSString *path = [[NSBundle mainBundle] pathForResource:@"ic_live_zhibozhong_28" ofType:@"gif"];
- YYAnimatedImageView *youpaipiconImgV = [[YYAnimatedImageView alloc] init];
- youpaipiconImgV.image = [YYImage imageWithData:[NSData dataWithContentsOfFile:path]];
-
- [youpaipleftTopBtn addSubview:youpaipiconImgV];
- [youpaipiconImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(3.0f);
- make.centerY.equalTo(youpaipleftTopBtn.mas_centerY);
- make.size.mas_offset(CGSizeMake(9.5f, 9.5f));
- }];
-
- UILabel *youpaiptextL = [[UILabel alloc] init];
- youpaiptextL.font = LCFont(8.0f);
- youpaiptextL.textColor = [UIColor whiteColor];
- youpaiptextL.text = @"直播中";
- [youpaipleftTopBtn addSubview:youpaiptextL];
- [youpaiptextL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(youpaipiconImgV.mas_right).offset(1.5f);
- make.centerY.equalTo(youpaipleftTopBtn.mas_centerY);
- }];
-
- UIView *footerV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, width, 20.0f)];
- CAGradientLayer *gradientLayerBot = [CAGradientLayer layer];
- gradientLayerBot.frame = footerV.bounds;
- //设置渐变颜色数组,可以加透明度的渐变
- gradientLayerBot.colors = @[(__bridge id)[[UIColor whiteColor] colorWithAlphaComponent:0.0f].CGColor,(__bridge id)[[UIColor blackColor] colorWithAlphaComponent:0.1f].CGColor];
- //设置渐变区域的起始和终止位置(范围为0-1)
- gradientLayerBot.startPoint = CGPointMake(0, 0.5f);
- gradientLayerBot.endPoint = CGPointMake(0, 1);
- [footerV.layer addSublayer:gradientLayerBot];
- [btn addSubview:footerV];
- [footerV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.bottom.right.offset(0.0f);
- make.height.offset(44.0f);
- }];
-
- UILabel *youpaipnicknameL = [[UILabel alloc] init];
- youpaipnicknameL.textColor = [UIColor whiteColor];
- youpaipnicknameL.font = LCFont(10);
- youpaipnicknameL.text = itemModel.youpaipanchor_name;
- [footerV addSubview:youpaipnicknameL];
-
- [youpaipnicknameL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(5.0f);
- make.bottom.offset(-3.0f);
- make.right.offset(-5.0f);
- }];
- }
- }
- - (void)youpaiftransformBtnClick{
- @weakify(self);
- [LCHttpHelper requestWithURLString:GetUserCloseLive parameters:@{@"is_refresh_rand":@(1)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- @strongify(self);
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- YOUPAILZLiveCloseModel *model = [YOUPAILZLiveCloseModel mj_objectWithKeyValues:[dict objectForKey:@"data"]];
- self.youpaipcloseModelmodel = model;
- [self youpaifcreateRecommendBtn];
- }else{
- [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
- }
- } failure:^(NSError *error) {
- [ZCHUDHelper showTitle:error.localizedDescription];
- }];
- }
- - (void)youpaifitemClick:(UIButton *)sender{
-
- YOUPAILZLiveListItemModel *model = self.youpaipcloseModelmodel.youpaiplive[sender.tag];
- // if (self.youpaipitemClickBlock != nil) {
- // self.youpaipitemClickBlock(self.youpaipcloseModelmodel.live[sender.tag]);
- // }
- [ZCHUDHelper showWithStatus:nil];
- @weakify(self);
- [LCHttpHelper requestWithURLString:JoinLive parameters:@{@"room_id":model.youpaiproom_id} needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
- @strongify(self);
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {
- [ZCHUDHelper dismiss];
- [[YOUPAILZChatRoomManager shareManager] youpaifcloseChatRoom];
- YOUPAILZLiveModel *youpaipliveModel = [YOUPAILZLiveModel mj_objectWithKeyValues:[dict objectForKey:@"data"]];
- if(youpaipliveModel.youpaiptype == 0){
-
- [UIView animateWithDuration:0.0 animations:^{
- self.frame = CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight);
- } completion:^(BOOL finished) {
- [self removeFromSuperview];
- }];
-
- YOUPAILZEndLiveHintModel *model1 = [YOUPAILZEndLiveHintModel mj_objectWithKeyValues:dict[@"data"][@"user_info"]];
- YOUPAILZEndLiveHintView *view = [[YOUPAILZEndLiveHintView alloc]initWithFrame:CGRectZero Model:model1];
-
- }else{
- [ZCHUDHelper dismiss];
- [UIView animateWithDuration:0.0 animations:^{
- self.frame = CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight);
- } completion:^(BOOL finished) {
- [self removeFromSuperview];
- }];
- [LCSaveData saveLiveRankTopThere:youpaipliveModel.youpaiprank_top_three];
- YOUPAILZLiveAudienceVC *audienceVC = [[YOUPAILZLiveAudienceVC alloc] initWithModel:youpaipliveModel];
- [[LCTools getCurrentVC].navigationController pushViewController:audienceVC animated:YES];
- }
- }else{
- [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
- }
- } failure:^(NSError *error) {
- [ZCHUDHelper showTitle:error.localizedDescription];
- }];
-
-
-
- }
- - (void)youpaifcloseBtnClick{
-
- [UIView animateWithDuration:0.0 animations:^{
- self.frame = CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight);
- } completion:^(BOOL finished) {
- [self removeFromSuperview];
- }];
- }
- /// 虚线
- - (CAShapeLayer *)youpaifdrawDashedLine{
- CAShapeLayer *shapeLayer = [CAShapeLayer layer];
- [shapeLayer setBounds:self.bounds];
- [shapeLayer setPosition:self.center];
- [shapeLayer setFillColor:[[UIColor clearColor] CGColor]];
- // 设置虚线颜色为blackColor
- [shapeLayer setStrokeColor:[HexColorFromRGB(0x999999) CGColor]];
- // 3.0f设置虚线的宽度
- [shapeLayer setLineWidth:0.5f];
- [shapeLayer setLineJoin:kCALineJoinRound];
- // 3=线的宽度 1=每条线的间距
- [shapeLayer setLineDashPattern:
- [NSArray arrayWithObjects:[NSNumber numberWithInt:5.0f],
- [NSNumber numberWithInt:1.0f],nil]];
- // Setup the path
- CGMutablePathRef path = CGPathCreateMutable();
- CGPathMoveToPoint(path, NULL, 0, 0);
- CGPathAddLineToPoint(path, NULL, KScreenWidth - 136.0f,0);
- [shapeLayer setPath:path];
- CGPathRelease(path);
- return shapeLayer;
- }
- @end
|