如何在iOS中绘制尾部具有动态角度和渐变效果的圆弧?
我可以使用Brezier路径和任何其他方法绘制圆/弧,甚至可以添加渐变效果,但我不知道如何在弧尾添加渐变效果?因为角度是动态的,所以会显示第一个圆,然后它会像删除一样显示,因为我实际上使用了圆填充和删除作为自定义进度条如何在iOS中绘制尾部具有动态角度和渐变效果的圆弧?,ios,objective-c,Ios,Objective C,我可以使用Brezier路径和任何其他方法绘制圆/弧,甚至可以添加渐变效果,但我不知道如何在弧尾添加渐变效果?因为角度是动态的,所以会显示第一个圆,然后它会像删除一样显示,因为我实际上使用了圆填充和删除作为自定义进度条 // Determine our start and stop angles for the arc (in radians) CGFloat startAngle = M_PI * 1.5; CGFloat endAngle = startAngle + (M_PI
// Determine our start and stop angles for the arc (in radians)
CGFloat startAngle = M_PI * 1.5;
CGFloat endAngle = startAngle + (M_PI * -2);
UIBezierPath* bezierPath = [UIBezierPath bezierPath];
// Create our arc, with the correct angles
[bezierPath addArcWithCenter:CGPointMake(70, 67)
radius:58
startAngle:startAngle
endAngle:(endAngle - startAngle) * (percent / 100.0) + startAngle
clockwise:false];
//Here percent is int according to which length or we can say angle of arc is decided. After fixed duration of time it changes so arc changes.
// Set the display for the path, and stroke it
bezierPath.lineWidth = 3.5;
[[UIColor greenColor] setStroke];
[bezierPath stroke];
我想在这个弧的尾部有一个渐变效果,随着弧的移动,渐变应该在弧的尾部移动
我想要类似的东西,但找不到答案
提前感谢。试试这个:
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetStrokeColorWithColor(context, [[UIColor blueColor] CGColor]);
UIBezierPath *blueHalf = [UIBezierPath bezierPath];
[blueHalf addArcWithCenter:CGPointMake(100, 100) radius:90.0 startAngle:-M_PI_2 endAngle:M_PI_2 clockwise:YES];
[blueHalf setLineWidth:4.0];
[blueHalf stroke];
CGContextSetStrokeColorWithColor(context, [[UIColor redColor] CGColor]);
UIBezierPath *redHalf = [UIBezierPath bezierPath];
[redHalf addArcWithCenter:CGPointMake(100.0, 100.0) radius:90.0 startAngle:M_PI_2 endAngle:3.0 * M_PI_2 clockwise:YES];
[redHalf setLineWidth:4.0];
[redHalf stroke];
}
你能发布一些代码或截图吗?这是你想要的吗?什么是弧的“尾巴”?弧的尾巴是指弧的末端。我链接的示例显示了一个弧-类似于我想你要求的-以及渐变中的颜色步骤。你有没有试过把尾部颜色的alpha设置为零?这会给你带来你想要的效果。