//创建XDColorCircle的实例化对象 XDColorCircle *circle=[[XDColorCircle alloc]initWithFrame:CGRectMake(0 ,100,self.view.frame.size.width,200)]; //添加到视图上展示 [self.view addSubview:circle];
//先都写在这个构造方法里面吧
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
}
return self;
}
self.backgroundColor=[UIColor clearColor];
UIView *circleView=[[UIView alloc]init];
circleView.frame=CGRectMake(0, 0,frame.size.width,frame.size.height);
circleView.backgroundColor=[UIColor blueColor];
[self addSubview: circleView];
CAGradientLayer * gradientLayer = [CAGradientLayer layer];
gradientLayer.colors = @[(__bridge id)[UIColor whiteColor].CGColor,(__bridge id)[UIColor cyanColor].CGColor];
gradientLayer.locations = @[@0.2,@1.0];
gradientLayer.startPoint = CGPointMake(0, 0);
gradientLayer.endPoint = CGPointMake(1.0, 0);
gradientLayer.frame =CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
[circleView.layer insertSublayer:_gradientLayer atIndex:0];
CAShapeLayer *layer=[[CAShapeLayer alloc]init];
CGMutablePathRef pathRef=CGPathCreateMutable();
CGPathAddRelativeArc(pathRef, nil,frame.size.width/2.0,frame.size.height/2.0,frame.size.width<frame.size.height?frame.size.width/2.0-5:frame.size.height/2.0-5,0, 2*M_PI);
layer.path=pathRef;
layer.lineWidth=5;
layer.fillColor=[UIColor clearColor].CGColor;
layer.strokeColor=[UIColor blackColor].CGColor;
CGPathRelease(pathRef);
circleView.layer.mask=layer;
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"];
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];
//创建XDColorCircle的实例化对象 XDColorCircle *circle=[[XDColorCircle alloc]initWithFrame:CGRectMake(0 ,100,self.view.frame.size.width,200)]; //添加到视图上展示 [self.view addSubview:circle];
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有