类似 刷新的时候 那个转圈圈 动画

    UILabel *label = [[UILabel alloc] init];
    label.frame = CGRectMake(150, 400, 50, 50);
    label.text = @"中";
    label.backgroundColor = [UIColor clearColor];
    label.textAlignment = NSTextAlignmentCenter;
    label.font = [UIFont systemFontOfSize:20.0f];
    [self.view addSubview:label];
    

    CGPoint point = CGPointMake(label.frame.size.width/2, label.frame.size.width/2);
    CGFloat ra = label.frame.size.width/2;
    CGFloat startAngle = 0;
    CGFloat endAngle = 0.9 * M_PI;
    CGFloat lineWidth = 4;
    
    
    UIBezierPath *path2 = [UIBezierPath bezierPathWithArcCenter:point radius:ra startAngle:startAngle endAngle:2*M_PI clockwise:YES];
    
    CAShapeLayer *shapeLayer2 = [CAShapeLayer layer];
    shapeLayer2.frame = label.bounds;
    shapeLayer2.strokeColor = [UIColor colorWithRed:191/255.0f green:191.0f/255.0f blue:191/255.0f alpha:1].CGColor;
    shapeLayer2.fillColor = [UIColor clearColor].CGColor;
    shapeLayer2.path = path2.CGPath;
    shapeLayer2.lineWidth = lineWidth;
    [label.layer addSublayer:shapeLayer2];

    
    UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:point radius:ra startAngle:startAngle endAngle:endAngle clockwise:YES];
    
    
    CAShapeLayer *shapeLayer = [CAShapeLayer layer];
    shapeLayer.frame = label.bounds;
    shapeLayer.strokeColor = [UIColor colorWithRed:131/255.0f green:131/255.0f blue:131/255.0f alpha:1].CGColor;
    shapeLayer.fillColor = [UIColor clearColor].CGColor;
    shapeLayer.path = path.CGPath;
    shapeLayer.lineWidth = lineWidth;
    [label.layer addSublayer:shapeLayer];
    
    CABasicAnimation *animate = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
    animate.byValue = @(M_PI*2);
    animate.duration = 1;
    animate.repeatCount = MAXFLOAT;
    [shapeLayer addAnimation:animate forKey:@"animate"];



  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值