From 56103bb220c77d0553665dcb55beb488777cb26f Mon Sep 17 00:00:00 2001 From: liyuhua <15626451870@163.com> Date: Wed, 15 Nov 2023 14:16:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=B5=E6=97=8F=E9=A3=98=E5=B1=8F=E5=8A=A8?= =?UTF-8?q?=E7=94=BB=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- YuMi/CustomUI/UIImage/UIImage+Utils.h | 1 + YuMi/CustomUI/UIImage/UIImage+Utils.m | 10 +- .../View/AnimationView/XPRoomAnimationView.m | 73 ++++++------ .../AnimationView/XPRoomNobleLevelUpView.m | 106 ++++++++---------- .../View/PIFullScreenBannerAnimation.h | 1 + .../View/PIFullScreenBannerAnimation.m | 65 ++++++----- .../YMTabbar/View/TabbarViewController.m | 6 +- 7 files changed, 132 insertions(+), 130 deletions(-) diff --git a/YuMi/CustomUI/UIImage/UIImage+Utils.h b/YuMi/CustomUI/UIImage/UIImage+Utils.h index 5c5d4261..8f34d092 100644 --- a/YuMi/CustomUI/UIImage/UIImage+Utils.h +++ b/YuMi/CustomUI/UIImage/UIImage+Utils.h @@ -51,4 +51,5 @@ typedef NS_ENUM(NSUInteger, GradientType) { -(UIImage *)compressWithMaxLength:(NSUInteger)maxLength; +- (UIImage *)roundedImageWithCornerRadius:(CGFloat)cornerRadius size:(CGSize)size; @end diff --git a/YuMi/CustomUI/UIImage/UIImage+Utils.m b/YuMi/CustomUI/UIImage/UIImage+Utils.m index 31159a1f..ea24ad7e 100644 --- a/YuMi/CustomUI/UIImage/UIImage+Utils.m +++ b/YuMi/CustomUI/UIImage/UIImage+Utils.m @@ -423,5 +423,13 @@ return self; } } - +- (UIImage *)roundedImageWithCornerRadius:(CGFloat)cornerRadius size:(CGSize)size{ + UIGraphicsBeginImageContextWithOptions(size, NO, 1); + UIBezierPath *clippingPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, size.width, size.height) cornerRadius:cornerRadius]; + [clippingPath addClip]; + [self drawInRect:CGRectMake(0, 0, size.width, size.height)]; + UIImage *roundedImage = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + return roundedImage; +} @end diff --git a/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.m b/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.m index af51ca3d..b88c89a9 100644 --- a/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.m +++ b/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.m @@ -1113,14 +1113,17 @@ #pragma mark - 贵族升级 - (void)receiveNobleLevelUp:(AttachmentModel *)attachment { - PIBaseAnimationViewModel *nobleModel = [PIBaseAnimationViewModel new]; - nobleModel.data = attachment.data; - nobleModel.type = GiftBannerType_Nobleman; + [[NetImageView new]loadImageWithUrl:attachment.data[@"avatar"] completion:^(UIImage * _Nonnull image, NSURL * _Nonnull url) { + PIBaseAnimationViewModel *nobleModel = [PIBaseAnimationViewModel new]; + nobleModel.data = attachment.data; + nobleModel.type = GiftBannerType_Nobleman; + + if (self.animationListB.count == 0 && self.isPlayOfB == NO) { + [self createNobleLevelUpBannerAnimation:nobleModel]; + } + [self.animationListB addObject:nobleModel]; + }]; - if (self.animationListB.count == 0 && self.isPlayOfB == NO) { - [self createNobleLevelUpBannerAnimation:nobleModel]; - } - [self.animationListB addObject:nobleModel]; } - (void)createNobleLevelUpBannerAnimation:(PIBaseAnimationViewModel *)model { @@ -1135,36 +1138,34 @@ springAnimation.springBounciness = 10.f; springAnimation.fromValue = [NSValue valueWithCGPoint:nobleLevelUpView.center]; springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(nobleLevelUpView.frame.size.width / 2, nobleLevelUpView.center.y)]; - [springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { - if (finished) { - POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter]; - moveAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(0, nobleLevelUpView.center.y)]; - moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2, nobleLevelUpView.center.y)]; - moveAnimation.beginTime = CACurrentMediaTime() + 3; - moveAnimation.duration = 0.5; - moveAnimation.repeatCount = 1; - moveAnimation.removedOnCompletion = YES; - @kWeakify(self); - [moveAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { - @kStrongify(self); - if (finished) { - self.isPlayOfB = NO; - [nobleLevelUpView removeFromSuperview]; - if (self.animationListB.count > 0) { - [self.animationListB removeObjectAtIndex:0]; - } - // if(self.isAnimationListAFinish == YES){ - // - // [self playAnimationWithModel]; - // self.isAnimationListAFinish = NO; - // return; - // } - [self playAnimationWithModel]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter]; + moveAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(0, nobleLevelUpView.center.y)]; + moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2, nobleLevelUpView.center.y)]; + moveAnimation.beginTime = CACurrentMediaTime() + 3; + moveAnimation.duration = 0.5; + moveAnimation.repeatCount = 1; + moveAnimation.removedOnCompletion = YES; + @kWeakify(self); + [moveAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { + @kStrongify(self); + if (finished) { + self.isPlayOfB = NO; + [nobleLevelUpView removeFromSuperview]; + if (self.animationListB.count > 0) { + [self.animationListB removeObjectAtIndex:0]; } - }]; - [nobleLevelUpView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"]; - } - }]; + // if(self.isAnimationListAFinish == YES){ + // + // [self playAnimationWithModel]; + // self.isAnimationListAFinish = NO; + // return; + // } + [self playAnimationWithModel]; + } + }]; + [nobleLevelUpView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"]; + }); [nobleLevelUpView pop_addAnimation:springAnimation forKey:@"nobleLevelUpspingOutAnimation"]; } diff --git a/YuMi/Modules/YMRoom/View/AnimationView/XPRoomNobleLevelUpView.m b/YuMi/Modules/YMRoom/View/AnimationView/XPRoomNobleLevelUpView.m index 1c1c5ac1..f8a310d1 100644 --- a/YuMi/Modules/YMRoom/View/AnimationView/XPRoomNobleLevelUpView.m +++ b/YuMi/Modules/YMRoom/View/AnimationView/XPRoomNobleLevelUpView.m @@ -21,12 +21,12 @@ ///贵族特效 @property (nonatomic,strong) SVGAImageView *nobleView; -@property (nonatomic, strong) UILabel *firstLabel; + ///用户头像 @property (nonatomic, strong) NetImageView *imageView; -///贵族信息 -@property (nonatomic, strong) UILabel *secondLabel; +///赠送内容 +@property(nonatomic,strong) MarqueeLabel *pi_contentView; @end @@ -44,6 +44,7 @@ #pragma mark - Private Method - (void)initSubViews { [self addSubview:self.nobleView]; + [self addSubview:self.pi_contentView]; } - (void)initSubViewConstraints { @@ -51,10 +52,16 @@ make.left.right.top.mas_equalTo(self); make.height.mas_equalTo(90); }]; + [self.pi_contentView mas_makeConstraints:^(MASConstraintMaker *make) { + + make.top.mas_equalTo(kGetScaleWidth(33)); + make.left.mas_equalTo(kGetScaleWidth(40)); + make.right.mas_equalTo(-kGetScaleWidth(40)); + }]; } - (NSMutableAttributedString *)createAttribute:(NSString * )text color:(UIColor *)color { - NSDictionary * attribute = @{NSFontAttributeName:[UIFont systemFontOfSize:22], NSForegroundColorAttributeName:color}; + NSDictionary * attribute = @{NSFontAttributeName:[UIFont systemFontOfSize:11], NSForegroundColorAttributeName:color}; NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:text attributes:attribute]; return attr; } @@ -62,62 +69,43 @@ #pragma mark - Getters And Setters - (void)setNobleInfo:(NSDictionary *)nobleInfo { _nobleInfo = nobleInfo; - self.imageView.imageUrl = nobleInfo[@"avatar"]; - if (nobleInfo) { @kWeakify(self); + self.imageView.imageUrl = nobleInfo[@"avatar"]; + NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init]; + [attribute appendAttributedString:[self createAttribute:YMLocalizedString(@"XPRoomNobleLevelUpView0") color:[UIColor whiteColor]]]; + + + NSTextAttachment * attachment = [[NSTextAttachment alloc] init]; + UIImage *iconImage = [self.imageView.image roundedImageWithCornerRadius:self.imageView.image.size.height/2 size:self.imageView.image.size]; + attachment.bounds = CGRectMake(0, roundf([UIFont systemFontOfSize:11].capHeight - 25)/2.f, 25, 25); + attachment.image =iconImage; + NSAttributedString * starAttribute = [NSMutableAttributedString attributedStringWithAttachment:(NSTextAttachment *)attachment]; + [attribute appendAttributedString:starAttribute]; + + NSMutableAttributedString * attribute1 = [[NSMutableAttributedString alloc] init]; + [attribute1 appendAttributedString:[self createAttribute:@" " color:[DJDKMIMOMColor giftBroadcastNumberColor]]]; + [attribute1 appendAttributedString:[self createAttribute:nobleInfo[@"nick"] color:[DJDKMIMOMColor giftBroadcastNumberColor]]]; + [attribute1 appendAttributedString:[self createAttribute:@" " color:[DJDKMIMOMColor giftBroadcastNumberColor]]]; + [attribute1 appendAttributedString:[self createAttribute:[NSString stringWithFormat:YMLocalizedString(@"XPRoomNobleLevelUpView1"), nobleInfo[@"currVipName"]] color:[UIColor whiteColor]]]; + [attribute appendAttributedString:attribute1]; + [self.parser parseWithURL:[NSURL URLWithString:nobleInfo[@"floatPic"]] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) { @kStrongify(self); self.nobleView.loops = 1; self.nobleView.clearsAfterStop = NO; self.nobleView.videoItem = videoItem; [self.nobleView startAnimation]; - } failureBlock:^(NSError * _Nullable error) { - + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + self.pi_contentView.attributedText = attribute; + }); + } failureBlock:^(NSError * _Nonnull error) { + }]; - ///绘制自定义view - [self.nobleView setDrawingBlock:^(CALayer *contentLayer, NSInteger frameIndex) { - @kStrongify(self); - CGFloat height = contentLayer.bounds.size.height; - CGFloat totalWidth = 0; - - NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init]; - [attribute appendAttributedString:[self createAttribute:YMLocalizedString(@"XPRoomNobleLevelUpView0") color:[UIColor whiteColor]]]; - CGFloat width1 = [attribute.string boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, height) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:22]} context:nil].size.width; - self.firstLabel.attributedText = attribute; - - NSMutableAttributedString * attribute1 = [[NSMutableAttributedString alloc] init]; - [attribute1 appendAttributedString:[self createAttribute:@" " color:[DJDKMIMOMColor giftBroadcastNumberColor]]]; - [attribute1 appendAttributedString:[self createAttribute:nobleInfo[@"nick"] color:[DJDKMIMOMColor giftBroadcastNumberColor]]]; - [attribute1 appendAttributedString:[self createAttribute:@" " color:[DJDKMIMOMColor giftBroadcastNumberColor]]]; - [attribute1 appendAttributedString:[self createAttribute:[NSString stringWithFormat:YMLocalizedString(@"XPRoomNobleLevelUpView1"), nobleInfo[@"currVipName"]] color:[UIColor whiteColor]]]; - CGFloat width2 = [attribute1.string boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, height) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:22]} context:nil].size.width; - self.secondLabel.attributedText = attribute1; - - totalWidth += ((width1 + width2) * 12/22 + 50); - CGFloat originL = (KScreenWidth - (totalWidth > KScreenWidth ? KScreenWidth : totalWidth)) * 0.5; - if (KScreenHeight != 667) {///在iOS14.0上的iPhone8上,无法显示头像,暂时隐藏头像 - self.firstLabel.layer.frame = CGRectMake(originL, 0, width1, height); - [contentLayer addSublayer:self.firstLabel.layer]; - UIImageView *imageView = [[UIImageView alloc] initWithImage:self.imageView.image]; - imageView.layer.frame = CGRectMake(originL + width1, (height - 50) * 0.5, 50, 50); - imageView.layer.cornerRadius = 25.0f; - imageView.layer.masksToBounds = YES; - [contentLayer addSublayer:imageView.layer]; - self.secondLabel.layer.frame = CGRectMake(originL + width1 + 50, 0, width2, height); - [contentLayer addSublayer:self.secondLabel.layer]; - } else { - totalWidth -= 50; - CGFloat originL = (KScreenWidth - (totalWidth > KScreenWidth ? KScreenWidth : totalWidth)) * 0.5; - self.firstLabel.layer.frame = CGRectMake(originL, 0, width1, height); - [contentLayer addSublayer:self.firstLabel.layer]; - self.secondLabel.layer.frame = CGRectMake(originL + width1, 0, width2, height); - [contentLayer addSublayer:self.secondLabel.layer]; - } - } forKey:@"noble_text_tx"]; } } + - (SVGAImageView *)nobleView { if (!_nobleView) { _nobleView = [[SVGAImageView alloc]init]; @@ -134,19 +122,7 @@ return _parser; } -- (UILabel *)firstLabel { - if (!_firstLabel) { - _firstLabel = [[UILabel alloc] init]; - } - return _firstLabel; -} -- (UILabel *)secondLabel{ - if (!_secondLabel) { - _secondLabel = [[UILabel alloc] init]; - } - return _secondLabel; -} - (NetImageView *)imageView { if (!_imageView) { @@ -157,5 +133,13 @@ } return _imageView; } - +- (MarqueeLabel *)pi_contentView{ + if(!_pi_contentView){ + _pi_contentView = [[MarqueeLabel alloc] init]; + _pi_contentView.scrollDuration = 6.0; + _pi_contentView.fadeLength = 8.0f; + _pi_contentView.textAlignment = NSTextAlignmentCenter; + } + return _pi_contentView; +} @end diff --git a/YuMi/Modules/YMTabbar/View/PIFullScreenBannerAnimation.h b/YuMi/Modules/YMTabbar/View/PIFullScreenBannerAnimation.h index e324db6f..68b31c56 100644 --- a/YuMi/Modules/YMTabbar/View/PIFullScreenBannerAnimation.h +++ b/YuMi/Modules/YMTabbar/View/PIFullScreenBannerAnimation.h @@ -18,6 +18,7 @@ NS_ASSUME_NONNULL_BEGIN -(void)receiveTarotBanner:(AttachmentModel *)attachment; -(void)receiveCommonH5Banner:(AttachmentModel *)attachment; - (void)receiveAnchorHourRank:(AttachmentModel *)attachment; +- (void)receiveNobleLevelUp:(AttachmentModel *)attachment; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMTabbar/View/PIFullScreenBannerAnimation.m b/YuMi/Modules/YMTabbar/View/PIFullScreenBannerAnimation.m index 814a7fdd..1a011966 100644 --- a/YuMi/Modules/YMTabbar/View/PIFullScreenBannerAnimation.m +++ b/YuMi/Modules/YMTabbar/View/PIFullScreenBannerAnimation.m @@ -540,14 +540,17 @@ } #pragma mark - 贵族升级 - (void)receiveNobleLevelUp:(AttachmentModel *)attachment { - PIBaseAnimationViewModel *nobleModel = [PIBaseAnimationViewModel new]; - nobleModel.data = attachment.data; - nobleModel.type = GiftBannerType_Nobleman; + [[NetImageView new]loadImageWithUrl:attachment.data[@"avatar"] completion:^(UIImage * _Nonnull image, NSURL * _Nonnull url) { + PIBaseAnimationViewModel *nobleModel = [PIBaseAnimationViewModel new]; + nobleModel.data = attachment.data; + nobleModel.type = GiftBannerType_Nobleman; + + if (self.animationListB.count == 0 && self.isPlayOfB == NO) { + [self createNobleLevelUpBannerAnimation:nobleModel]; + } + [self.animationListB addObject:nobleModel]; + }]; - if (self.animationListB.count == 0 && self.isPlayOfB == NO) { - [self createNobleLevelUpBannerAnimation:nobleModel]; - } - [self.animationListB addObject:nobleModel]; } - (void)createNobleLevelUpBannerAnimation:(PIBaseAnimationViewModel *)model { @@ -557,41 +560,41 @@ XPRoomNobleLevelUpView *nobleLevelUpView = [[XPRoomNobleLevelUpView alloc] initWithFrame:CGRectMake(KScreenWidth, top, KScreenWidth, 90)]; nobleLevelUpView.nobleInfo = model.data; [kWindow addSubview:nobleLevelUpView]; + POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter]; springAnimation.springSpeed = 12; springAnimation.springBounciness = 10.f; springAnimation.fromValue = [NSValue valueWithCGPoint:nobleLevelUpView.center]; springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(nobleLevelUpView.frame.size.width / 2, nobleLevelUpView.center.y)]; - [springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { - if (finished) { - POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter]; - moveAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(0, nobleLevelUpView.center.y)]; - moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2, nobleLevelUpView.center.y)]; - moveAnimation.beginTime = CACurrentMediaTime() + 3; - moveAnimation.duration = 0.5; - moveAnimation.repeatCount = 1; - moveAnimation.removedOnCompletion = YES; - @kWeakify(self); - [moveAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { - @kStrongify(self); - if (finished) { - self.isPlayOfB = NO; - [nobleLevelUpView removeFromSuperview]; - if (self.animationListB.count > 0) { - [self.animationListB removeObjectAtIndex:0]; - } + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(6.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter]; + moveAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(0, nobleLevelUpView.center.y)]; + moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2, nobleLevelUpView.center.y)]; + moveAnimation.beginTime = CACurrentMediaTime() + 3; + moveAnimation.duration = 0.5; + moveAnimation.repeatCount = 1; + moveAnimation.removedOnCompletion = YES; + @kWeakify(self); + [moveAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { + @kStrongify(self); + if (finished) { + self.isPlayOfB = NO; + [nobleLevelUpView removeFromSuperview]; + if (self.animationListB.count > 0) { + [self.animationListB removeObjectAtIndex:0]; + } // if(self.isAnimationListAFinish == YES){ // // [self playAnimationWithModel]; // self.isAnimationListAFinish = NO; // return; // } - [self playAnimationWithModel]; - } - }]; - [nobleLevelUpView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"]; - } - }]; + [self playAnimationWithModel]; + } + }]; + [nobleLevelUpView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"]; + }); + [nobleLevelUpView pop_addAnimation:springAnimation forKey:@"nobleLevelUpspingOutAnimation"]; } #pragma mark - 收到星级厨房飘屏 diff --git a/YuMi/Modules/YMTabbar/View/TabbarViewController.m b/YuMi/Modules/YMTabbar/View/TabbarViewController.m index 24be470c..5a34b27d 100644 --- a/YuMi/Modules/YMTabbar/View/TabbarViewController.m +++ b/YuMi/Modules/YMTabbar/View/TabbarViewController.m @@ -172,8 +172,8 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showNewUserRecharge) name:kNewUserRechargeKey object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showAnchorCardKey:) name:kTabShowAnchorCardKey object:nil]; - + @@ -630,6 +630,10 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; } else if (attachment.first == CustomMessageType_Licnese_Hour_Rank && attachment.second == Custom_Message_Sub_Licnese_Hour_Rank) {///牌照房小时榜 if([XPSkillCardPlayerManager shareInstance].isInRoomVC == YES)return; [self.roomAnimation receiveAnchorHourRank:attachment]; + }else if (attachment.first == CustomMessageType_Noble_VIP && attachment.second == Custom_Message_Sub_Room_Noble_LevelUp_Suspend) {///贵族升级全服飘屏 + if([XPSkillCardPlayerManager shareInstance].isInRoomVC == YES)return; + [self.roomAnimation receiveNobleLevelUp:attachment]; + } } }