我想创建一个具有弧形的进度条.进度条的颜色必须根据值进行更改.
我使用创建了一个弧UIBezierPath bezierPathWithArcCenter.我使用了以下代码:
- (void)viewDidLoad
{
[super viewDidLoad];
int radius = 100;
CAShapeLayer *arc = [CAShapeLayer layer];
arc.path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(100, 50) radius:radius startAngle:60.0 endAngle:0.0 clockwise:YES].CGPath;
arc.position = CGPointMake(CGRectGetMidX(self.view.frame)-radius,
CGRectGetMidY(self.view.frame)-radius);
arc.fillColor = [UIColor clearColor].CGColor;
arc.strokeColor = [UIColor purpleColor].CGColor;
arc.lineWidth = 15;
[self.view.layer addSublayer:arc];
CABasicAnimation *drawAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
drawAnimation.duration = 5.0; // "animate over 10 seconds or so.."
drawAnimation.repeatCount = 1.0; // Animate only once..
drawAnimation.removedOnCompletion = NO; // Remain stroked after the animation..
drawAnimation.fromValue = [NSNumber numberWithFloat:0.0f]; …Run Code Online (Sandbox Code Playgroud) 我是Core Graphics的新手,我想知道如何使用类似于Apple Watch健身应用程序的渐变绘制环.我试图在iOS应用程序上执行此操作,因为我认为目前尚未在WatchKit上支持Core Graphics.
我在以下网站上找到了一个非常好的教程来绘制戒指.
http://makeapppie.com/2015/03/10/swift-swift-basic-core-graphics-for-the-ring-graph/
但是我想弄清楚如何为笔触颜色添加渐变.到目前为止,基于我发现的,没有直接的方法来做到这一点.为了达到这个目的,我想我需要找到以下答案:
谢谢