让圈圈转起来添加动画
CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; ;
// 设定动画选项
animation.duration = 1;
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeForwards;
animation.repeatCount =HUGE_VALF;
// 设定旋转角度
animation.fromValue = [NSNumber numberWithFloat:0.0]; // 起始角度
animation.toValue = [NSNumber numberWithFloat:2 * M_PI]; // 终止角度
[circleView.layer addAnimation:animation forKey:@"rotate-layer"];
添加中间的大文字Label
UILabel *label=[[UILabel alloc]init];
label.text=@"测试中";
label.font=[UIFont systemFontOfSize:32];
label.textAlignment=NSTextAlignmentCenter;
label.frame=CGRectMake(0, 0,frame.size.width,frame.size.height);
label.backgroundColor=[UIColor clearColor];
[self addSubview:label];
4.然后在controller里面使用
//创建XDColorCircle的实例化对象
XDColorCircle *circle=[[XDColorCircle alloc]initWithFrame:CGRectMake(0 ,100,self.view.frame.size.width,200)];
//添加到视图上展示
[self.view addSubview:circle];

只是个简单的动画实现小例子,可以看出活用CAShapeLayer和CABasicAnimation可以做出更炫的动画效果
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持ASPKU。
注:相关教程知识阅读请移步到IOS开发频道。










