Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修改中间动画(仿造系统的弹窗动画) #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions GKCover/GKCover.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -911,7 +924,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;
Expand Down