From 36e16bd17cc7db9d9f26787f260081d8e23ea6da Mon Sep 17 00:00:00 2001 From: YJExpand Date: Tue, 26 Nov 2019 15:13:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=AD=E9=97=B4=E5=8A=A8?= =?UTF-8?q?=E7=94=BB=EF=BC=88=E4=BB=BF=E9=80=A0=E7=B3=BB=E7=BB=9F=E7=9A=84?= =?UTF-8?q?=E5=BC=B9=E7=AA=97=E5=8A=A8=E7=94=BB=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GKCover/GKCover.m | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/GKCover/GKCover.m b/GKCover/GKCover.m index 57cf14b..1e489d3 100644 --- a/GKCover/GKCover.m +++ b/GKCover/GKCover.m @@ -355,16 +355,26 @@ + (void)showContentView */ + (void)animationAlert:(UIView*)view{ CAKeyframeAnimation* animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"]; - animation.duration = 0.5; + animation.duration = 0.4; animation.delegate = _cover; + NSMutableArray *timingFunctions = [NSMutableArray array]; NSMutableArray *values = [NSMutableArray array]; - [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1, 0.1, 1.0)]]; [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.2, 1.2, 1.0)]]; - [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9, 0.9, 1.0)]]; [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)]]; + + [timingFunctions addObject:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]]; + [timingFunctions addObject:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]]; + animation.values = values; + animation.keyTimes = [[NSArray alloc] initWithObjects: + [[NSNumber alloc] initWithDouble:0.0] + ,[[NSNumber alloc] initWithDouble:0.5], + [[NSNumber alloc] initWithDouble:0.75], + [[NSNumber alloc] initWithDouble:1.0], nil]; + animation.timingFunctions = timingFunctions; + [view.layer addAnimation:animation forKey:nil]; } @@ -791,6 +801,9 @@ + (void)coverHideStatusBarWithContentView:(UIView *)contentView style:(GKCoverSt + (void)showCover { [_fromView addSubview:_contentView]; + /// 主要是为了中间动画 + _contentView.alpha = 1; + switch (_showStyle) { case GKCoverShowStyleTop: { // 显示在顶部 _contentView.gk_centerX = _fromView.gk_centerX; @@ -909,7 +922,12 @@ + (void)hideCover { [self remove]; }]; }else if (_hideAnimStyle == GKCoverHideAnimStyleCenter) { // 中间动画 - [self remove]; + [UIView animateWithDuration:kAnimDuration animations:^{ + _contentView.alpha = 0; + _cover.alpha = 0; + } completion:^(BOOL finished) { + [self remove]; + }]; }else if (_hideAnimStyle == GKCoverHideAnimStyleBottom) { // 下出 [UIView animateWithDuration:kAnimDuration animations:^{ _contentView.gk_y = _fromView.gk_height;