- (void)doShowupAnimation {
CABasicAnimation* scaleAnima = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
scaleAnima.fromValue = @0.8;
scaleAnima.toValue = @1;
scaleAnima.timingFunction = [CAMediaTimingFunction functionWithName:
kCAMediaTimingFunctionEaseIn];
CABasicAnimation *opacityAnima = [CABasicAnimation animationWithKeyPath:@"opacity"];
opacityAnima.fromValue = @(0);
opacityAnima.toValue = @(1);
opacityAnima.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
CAAnimationGroup *animaGroup = [CAAnimationGroup animation];
animaGroup.duration = 0.15f;
animaGroup.fillMode = kCAFillModeForwards;
animaGroup.removedOnCompletion = NO;
animaGroup.animations = @[scaleAnima,opacityAnima];
[self.containerView.layer addAnimation:animaGroup forKey:@"showup"];
}
- (void)doDismissAnimation: (void(^)(Boolean)) completionHandler {
CABasicAnimation* scaleAnima = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
scaleAnima.fromValue = @1;
scaleAnima.toValue = @0.8;
scaleAnima.timingFunction = [CAMediaTimingFunction functionWithName:
kCAMediaTimingFunctionEaseIn];
CABasicAnimation *opacityAnima = [CABasicAnimation animationWithKeyPath:@"opacity"];
opacityAnima.fromValue = @(1);
opacityAnima.toValue = @(0);
opacityAnima.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
CAAnimationGroup *animaGroup = [CAAnimationGroup animation];
animaGroup.duration = 0.15f;
animaGroup.fillMode = kCAFillModeForwards;
animaGroup.removedOnCompletion = NO;
animaGroup.animations = @[scaleAnima,opacityAnima];
animaGroup.delegate = self;
[self.containerView.layer addAnimation:animaGroup forKey:@"dismiss"];
}
网友评论