gpt4 book ai didi

ios - lineWidth 未正确渲染贝塞尔曲线宽度

转载 作者:行者123 更新时间:2023-11-29 10:28:54 25 4
gpt4 key购买 nike

我正在使用 lineWidth 创建笔画宽度为 4 的圆。我正在使用 UIBezierPath 创建圆。但是,由于某种原因,无论我为 lineWidth 分配什么值,lineWidth 总是渲染一个带有细笔划的圆。我也尝试过设置 path.lineWidth = 100.0,但笔划宽度没有变化。

这是我的代码:

UIGraphicsBeginImageContextWithOptions(CGSizeMake(progressView.frame.size.width, progressView.frame.size.height), NO, 0.0);

[[UIColor colorWithRed:246.0/255.0 green:80.0/255.0 blue:36.0/255.0 alpha:1.0] setStroke];

UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(progressView.frame.size.width/2 ,progressView.frame.size.height/2) radius:progressView.frame.size.width/2 - 5 startAngle:DEGREES_TO_RADIANS(0) endAngle:DEGREES_TO_RADIANS(angle) clockwise:YES];
[path stroke];
path.lineWidth = 4;
UIImage* pathImg = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

[progressView setImage:pathImg];

我在谷歌上搜索了很多,但找不到解决这个问题的方法。

最佳答案

您需要在实际描边路径之前设置描边宽度:

UIGraphicsBeginImageContextWithOptions(CGSizeMake(progressView.frame.size.width, progressView.frame.size.height), NO, 0.0);
[[UIColor colorWithRed:246.0/255.0 green:80.0/255.0 blue:36.0/255.0 alpha:1.0] setStroke];
UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(progressView.frame.size.width/2 ,progressView.frame.size.height/2) radius:progressView.frame.size.width/2 - 5 startAngle:DEGREES_TO_RADIANS(0) endAngle:DEGREES_TO_RADIANS(angle) clockwise:YES];
path.lineWidth = 4;
[path stroke];
UIImage* pathImg = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

[progressView setImage:pathImg];

关于ios - lineWidth 未正确渲染贝塞尔曲线宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30689079/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com