简体   繁体   English

UIBezierPath圆边?

[英]UIBezierPath round edges?

Im drawing some lines and I noticed that when the edges get at a certain angle it generates a sharp edge like this: 我画了一些线条,我注意到当边缘达到某个角度时,它会产生一个像这样的尖锐边缘: 尖尖的边缘

What I want it to draw: 我想要它绘制: 圆边

How do I do this? 我该怎么做呢? I have looked through the documentations but I dont seem to find anything im looking for. 我查看了文档,但我似乎找不到任何我正在寻找的东西。 Or is there a way to turn that auto-edge-generating off? 或者有没有办法将自动边缘生成关闭?

UIBezierPath's have a property called lineJoinStyle . UIBezierPath有一个名为lineJoinStyle的属性。 Set it to kCGLineJoinRound and it will draw as you want it. 将它设置为kCGLineJoinRound ,它将根据您的需要绘制。

UIBezierPath *myPath = ...
myPath.lineJoinStyle = kCGLineJoinRound;

可以通过以下方式在Swift中调用UIBezierPath上的kCGLineJoinRound属性:

myPath.lineJoinStyle = .round

Use CGContextSetLineJoin to set your drawing context's join parameter to kCGLineJoinRound , before you stroke the path. 在描边路径之前,使用CGContextSetLineJoin将绘图上下文的连接参数设置为kCGLineJoinRound This is documented in the Quartz 2D Programming Guide . 这在Quartz 2D Programming Guide中有记载。

If you are drawing a UIBezierPath, you can also set the path's lineJoinStyle , which may be easier. 如果您正在绘制UIBezierPath,您还可以设置路径的lineJoinStyle ,这可能更容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM