问题
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