点击图片旋转动画和放大动画
2019-07-26 本文已影响0人
timeQuick
在工程中比较常写的2种
点击按钮图片旋转来表示刷新
-(void)animateRotation
{
dispatch_async(dispatch_get_main_queue(), ^{
CABasicAnimation *layer = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
layer.toValue = @(2*M_PI);
layer.duration = 1;
layer.removedOnCompletion = false;
layer.repeatCount = MAXFLOAT;
[self.refreshImageView.layer addAnimation:layer forKey:@"xuanzhuangXX"];
});
}
-(void)removeAnimate
{
[self.refreshImageView.layer removeAllAnimations];
}
放大动画
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
animation.repeatCount = 1;
animation.duration = 0.2;
animation.fillMode = kCAFillModeForwards;
animation.removedOnCompletion = YES;
animation.values = @[@(1), @(1.5), @(1)];
[view.layer addAnimation:animation forKey:@"beginaniamtion"];