#pragma mark 添加动画
-(void)addZoomInAnimationWithView:(UIView*)view{
//放大动画
CABasicAnimation *animationZoomIn = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
animationZoomIn.duration = 0.3f;
animationZoomIn.autoreverses = NO;
animationZoomIn.repeatCount = 1;
animationZoomIn.fromValue = [NSNumber numberWithFloat:0.01];
animationZoomIn.toValue = [NSNumber numberWithFloat:1.0];
animationZoomIn.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
[view.layer addAnimation:animationZoomIn forKey:@"scale-layer"];
}
-(void)addZoomOutAnimationWithView:(UIView*)view{
//缩小动画
CABasicAnimation *animationZoomOut = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
animationZoomOut.delegate = self;
animationZoomOut.duration = 0.3f;
animationZoomOut.autoreverses = NO;
animationZoomOut.repeatCount = 1;
animationZoomOut.toValue = [NSNumber numberWithFloat:.01];
animationZoomOut.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
//动画完成后不再回返
animationZoomOut.fillMode = kCAFillModeForwards;
animationZoomOut.removedOnCompletion = NO;
[view.layer addAnimation:animationZoomOut forKey:@"scale-layer"];
}
iOS动画那些事
最新推荐文章于 2023-05-27 18:57:56 发布