[英]Swift 3, draw circle with special lineCap
Currently I'm using CAShapeLayer and UIBezierPath to draw a line for avatar. 目前,我正在使用CAShapeLayer和UIBezierPath绘制头像线。 It's Ok for the normal one with lineCap = kCALineCapRound .
正常情况下,使用lineCap = kCALineCapRound即可 。 BUT I've been STRUGGLING to draw line with START and END lineCap like image below:
但是我一直在努力用START和END lineCap画线,如下图所示:
You can't draw this circle with a shape layer, because a shape layer supports only one single stroke color. 您无法使用形状图层绘制此圆形,因为形状图层仅支持一种笔触颜色。 You should write your own layer class where you should draw three separate circle segments with
kCALineCapRound
: 您应该编写自己的图层类,在其中应使用
kCALineCapRound
绘制三个单独的圆形线段:
You should use CGPath
and CGContext
instead of UIBezierPath
. 您应该使用
CGPath
和CGContext
而不是UIBezierPath
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.