Rounding the edges of a stroke in bezier path circle in swift

烂漫一生 提交于 2021-01-21 01:41:31

问题


I'm trying to draw a circle using UIBezierPath(ovalInRect: CGRectMake()). Then I'll change the strokeEnd property. When this happens, either end of the circular line have sharp corners. Is there any way to round out these corners?

(I would like to make the beginning and end of this line curved)


回答1:


Assuming you are using a CAShapeLayer to draw this, just set the lineCap, e.g.:

layer.lineCap = .round



回答2:


For drawRect based solutions use lineCapStyle

let path = UIBezierPath(...) path.lineCapStyle = .round



来源:https://stackoverflow.com/questions/34373781/rounding-the-edges-of-a-stroke-in-bezier-path-circle-in-swift

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