feat: 修正最后验收问题
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
#import "GameUniversalBannerView.h"
|
||||
|
||||
#import <POP.h>
|
||||
#import <SVGA.h>
|
||||
#import "AttachmentModel.h"
|
||||
#import "PIUniversalBannerModel.h"
|
||||
@@ -45,26 +46,74 @@
|
||||
bannerView.gameID = model.skipContent;
|
||||
[superView addSubview:bannerView];
|
||||
|
||||
// TODO: 添加手势 | 调整为 pop 动画
|
||||
|
||||
[bannerView addNotification];
|
||||
|
||||
@kWeakify(bannerView);
|
||||
[UIView animateWithDuration:0.25 animations:^{
|
||||
bannerView.center = CGPointMake(superView.center.x, height/2 + 0);
|
||||
} completion:^(BOOL finished) {
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[UIView animateWithDuration:0.25 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
|
||||
bannerView.frame = CGRectMake(-KScreenWidth, 0, width, height);
|
||||
} completion:^(BOOL finished) {
|
||||
[bannerView popEnterAnimation:^(BOOL finished) {
|
||||
if (finished) {
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
@kStrongify(bannerView);
|
||||
[bannerView removeFromSuperview];
|
||||
if (bannerView.completeDisplay) {
|
||||
bannerView.completeDisplay();
|
||||
}
|
||||
}];
|
||||
});
|
||||
[bannerView popLeaveAnimation:^(bool finished) {
|
||||
if (bannerView.completeDisplay) {
|
||||
bannerView.completeDisplay();
|
||||
}
|
||||
[bannerView removeFromSuperview];
|
||||
}];
|
||||
});
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)addNotification {
|
||||
@kWeakify(self);
|
||||
[[NSNotificationCenter defaultCenter] addObserverForName:@"SwipeOutBanner"
|
||||
object:nil
|
||||
queue:[NSOperationQueue mainQueue]
|
||||
usingBlock:^(NSNotification * _Nonnull notification) {
|
||||
@kStrongify(self);
|
||||
[self dismissBanner];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)dismissBanner {
|
||||
[self pop_removeAllAnimations]; // 停止所有动画
|
||||
|
||||
[self popLeaveAnimation:^(bool finished) {
|
||||
if (self.completeDisplay) {
|
||||
self.completeDisplay();
|
||||
}
|
||||
[self removeFromSuperview];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)popEnterAnimation:(void(^)(BOOL finished))finish {
|
||||
NSInteger height = kGetScaleWidth(70);
|
||||
POPSpringAnimation *enterAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewFrame];
|
||||
enterAnimation.toValue = [NSValue valueWithCGRect:CGRectMake(0, 0, KScreenWidth, height)];
|
||||
enterAnimation.springBounciness = 10; // 弹性系数
|
||||
enterAnimation.springSpeed = 12; // 动画速度
|
||||
enterAnimation.completionBlock = ^(POPAnimation *anim, BOOL finished) {
|
||||
if (finish) {
|
||||
finish(finished);
|
||||
}
|
||||
};
|
||||
[self pop_addAnimation:enterAnimation forKey:@"enterAnimation"];
|
||||
}
|
||||
|
||||
- (void)popLeaveAnimation:(void(^)(bool finished))finish {
|
||||
NSInteger height = kGetScaleWidth(70);
|
||||
POPBasicAnimation *exitAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewFrame];
|
||||
exitAnimation.toValue = [NSValue valueWithCGRect:CGRectMake(-KScreenWidth, 0, KScreenWidth, height)];
|
||||
exitAnimation.duration = 0.25; // 动画持续时间
|
||||
exitAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
|
||||
exitAnimation.completionBlock = ^(POPAnimation *anim, BOOL finished) {
|
||||
if (finish) {
|
||||
finish(finished);
|
||||
}
|
||||
};
|
||||
[self pop_addAnimation:exitAnimation forKey:@"exitAnimation"];
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
[self addSubview:self.bgSVGA];
|
||||
|
Reference in New Issue
Block a user