iOS开发交流群:301058503
1、 旋转的加载动画,效果图如下
代码实现
/*慢慢消失的动画*/
CABasicAnimation *animation1 = [CABasicAnimation animationWithKeyPath:@"opacity"];
//动画完成后保持原状
animation1.fillMode = kCAFillModeForwards;
animation1.removedOnCompletion = NO;
//值
animation1.fromValue = [NSNumber numberWithFloat:1.0];
animation1.toValue = [NSNumber numberWithFloat:0];
animation1.duration = 1.2;//动画时间
/*旋转动画*/
NSString *keyPath = @"transform.rotation.z";//绕z轴旋转(大家可以试试x,y轴,看看效果)
CABasicAnimation *animation2 = [CABasicAnimation animationWithKeyPath:keyPath];
animation2.fillMode = kCAFillModeForwards;
animation2.removedOnCompletion = NO;
//值
animation2.fromValue = [NSNumber numberWithFloat:0];
animation2.toValue = [NSNumber numberWithFloat:1.5*M_PI];
animation2.duration = 1.2;
/*动画组,把上面两个动画组合起来*/
CAAnimationGroup *groupAnnimation = [CAAnimationGroup animation];
groupAnnimation.duration = 1.5;
groupAnnimation.repeatCount = MAXFLOAT;//无限循环
groupAnnimation.animations = @[animation1, animation2];
groupAnnimation.fillMode = kCAFillModeForwards;
groupAnnimation.removedOnCompletion = NO;
[imageView.layer addAnimation:groupAnnimation forKey:@"group"];
2、正在录音的波纹动画,效果图如下
代码实现
UIView *animationView = [[U