【发布时间】:2016-01-19 12:32:07
【问题描述】:
我正在尝试绘制一个光标,并且我已经使用 UIBezierPath 来做到这一点。
这就是我所做的:
从顶部指针到右边缘画线。
从顶部指针到左边缘画线。
将 bezierPath 设置为具有宽度的层。
代码如下:
cursorLayerPathPointTop = UIBezierPath()
cursorLayerPathPointTop.lineJoinStyle = CGLineJoin.Round
cursorLayerPathPointTop.lineCapStyle = CGLineCap.Round
cursorLayerPathPointTop.lineWidth = 20
cursorLayerPathPointTop.moveToPoint(cursor_point_top)
cursorLayerPathPointTop.addLineToPoint(cursorRightPoint)
cursorLayerPathPointTop.moveToPoint(cursor_point_top)
cursorLayerPathPointTop.addLineToPoint(cursorLeftPoint)
//adding calyer
cursorLayer = CAShapeLayer()
cursorLayer.lineWidth = 3.0;
cursorLayer.path = cursorLayerPathPointTop.CGPath
cursorLayer.strokeColor = UIColor.whiteColor().CGColor
self.layer.addSublayer(cursorLayer)
我需要把光标变粗,这样设置cursorLayer.lineWidth = 3.0;的原因。
但这是我得到的:
正如你所看到的指针,线条没有平滑地连接在一起。我应该怎么做才能解决这个问题?
【问题讨论】:
标签: ios uibezierpath cashapelayer