UIBezierPath round edges?

*爱你&永不变心* 提交于 2019-11-30 03:09:46

问题


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?


回答1:


UIBezierPath's have a property called lineJoinStyle. Set it to kCGLineJoinRound and it will draw as you want it.

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



回答2:


kCGLineJoinRound property on a UIBezierPath can be called in Swift by:

myPath.lineJoinStyle = .round



回答3:


Use CGContextSetLineJoin to set your drawing context's join parameter to kCGLineJoinRound, before you stroke the path. This is documented in the Quartz 2D Programming Guide.

If you are drawing a UIBezierPath, you can also set the path's lineJoinStyle, which may be easier.



来源:https://stackoverflow.com/questions/18167327/uibezierpath-round-edges

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!