贵族飘屏动画更改

This commit is contained in:
liyuhua
2023-11-15 14:16:01 +08:00
parent cee26a4c25
commit 56103bb220
7 changed files with 132 additions and 130 deletions

View File

@@ -51,4 +51,5 @@ typedef NS_ENUM(NSUInteger, GradientType) {
-(UIImage *)compressWithMaxLength:(NSUInteger)maxLength;
- (UIImage *)roundedImageWithCornerRadius:(CGFloat)cornerRadius size:(CGSize)size;
@end

View File

@@ -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

View File

@@ -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"];
}

View File

@@ -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.0iPhone8
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

View File

@@ -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

View File

@@ -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 -

View File

@@ -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];
}
}
}