我正在使用copy(strokingWithWidth:lineCap:lineJoin:miterLimit:transform:)来偏移CGPath。问题在于,偏移路径引入了各种各样的锯齿状线条,似乎是斜接的结果。将
在这张图片中,有原始路径(在应用
使用斜角的代码:
miterLimit
更改为0没有任何效果,使用斜角线连接也没有任何区别。在这张图片中,有原始路径(在应用
strokingWithWidth
之前),使用斜接连接的偏移路径和使用斜角连接的偏移路径。为什么使用斜角连接没有任何影响?
使用斜接连接的代码(请注意,使用 CGLineJoin.round
会产生相同的结果):let pathOffset = path.copy(strokingWithWidth: 4.0,
lineCap: CGLineCap.butt,
lineJoin: CGLineJoin.miter,
miterLimit: 20.0)
context.saveGState()
context.setStrokeColor(UIColor.red.cgColor)
context.addPath(pathOffset)
context.strokePath()
context.restoreGState()
使用斜角的代码:
let pathOffset = path.copy(strokingWithWidth: 4.0,
lineCap: CGLineCap.butt,
lineJoin: CGLineJoin.bevel,
miterLimit: 0.0)
context.saveGState()
context.setStrokeColor(UIColor.red.cgColor)
context.addPath(pathOffset)
context.strokePath()
context.restoreGState()
context.setLineJoin(.bevel)
的代码呢? - rob mayoffcopy(strokingWithWidth:lineCap:lineJoin:miterLimit:transform:)
)? 如果找不到,我可能不得不自己编写。 - Duncan C