gpt4 book ai didi

iOS Swift 描边宽度

转载 作者:搜寻专家 更新时间:2023-10-30 21:57:57 25 4
gpt4 key购买 nike

在 UIView 中绘制不同的形状时,lineWidth 出现问题。附图中的所有形状的线宽都应为 3。这是我使用的代码:

 var path:UIBezierPath = UIBezierPath()
path.moveToPoint(CGPoint(x: 0.0, y: 0.0))
path.addLineToPoint(CGPoint(x: 0.0, y: 50.0))
path.lineWidth = 3.0
path.stroke()

enter image description here正如您在图片中看到的,只有圆圈具有 3px 的真实笔划大小。时钟的指针都是 2px(这就是它们对齐不好的原因)。

你能帮帮我吗?

最佳答案

我想通了,所以我会为有兴趣的人发布答案。线条描边绘制在形状的每一侧。因此,就我而言,我开始在点 (0,0) 到 (0,50) 处绘图。左侧被剪裁,只绘制右侧。将代码更改为

path.moveToPoint(CGPoint(x: 1.0, y: 0.0))
path.addLineToPoint(CGPoint(x: 1.0, y: 50.0))

解决了问题。

关于iOS Swift 描边宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26190301/

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