Bri*_*ure 5 core-graphics ios uibezierpath swift
这是我的代码:
let cross = UIBezierPath()
cross.move(to: CGPoint(x: skull.bounds.maxX, y: skull.bounds.minY))
cross.addLine(to: CGPoint(x: skull.bounds.minX, y: skull.bounds.maxY))
cross.close()
UIColor.red.set()
cross.lineWidth = 3.0
cross.lineCapStyle = .round
cross.stroke()
Run Code Online (Sandbox Code Playgroud)
我想围绕线的末端,但它仍然是正方形,我应该怎么做?
刚刚在PlayGround上测试过,希望它会有所帮助
let cross = UIBezierPath()
cross.moveToPoint(CGPoint(x: 10, y: 100)) // your point
cross.addLineToPoint(CGPoint(x: 100, y: 10)) // your point
cross.closePath()
cross.lineWidth = 23.0
cross.lineJoinStyle = .Round
cross.stroke()
Run Code Online (Sandbox Code Playgroud)
结果
该线帽风格配置的行结束的风格。您已关闭路径,即没有行尾。
您可能正在寻找线连接样式,该样式会影响路径的所有“角”或“顶点”。
另外,如果您只想要一条直线,请不要闭合路径。否则,您将获得两个线段:一个从起点到终点,另一个从起点回到起点。
Swift 4.1 更新 Umair Afzal 的代码:
let cross = UIBezierPath()
cross.move(to: CGPoint(x: 10, y: 100)) // your point
cross.addLine(to: CGPoint(x: 100, y: 10)) // your point
cross.lineWidth = 12
cross.lineCapStyle = .round
cross.stroke()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3214 次 |
| 最近记录: |