0
我已經看到了這一點How to get a border on UIBezierPath的曲線形狀圖層繪製邊框
我希望藉助曲線邊框
我畫曲線與下面的方法
func drawCurve(from startPoint: CGPoint, to endPoint: CGPoint, controlPoint: CGPoint) {
var bezierPath = UIBezierPath()
bezierPath.move(to: startPoint)
// bezierPath.addQuadCurve(to: endPoint, controlPoint: CGPoint
bezierPath.addLine(to: controlPoint)
bezierPath.addLine(to: endPoint);
bezierPath = bezierPath.bezierCardinal(withTension: 2.06)
curveSize = bezierPath.bounds
let strokeColor = UIColor.white
if curveLayer != nil {
curveLayer?.removeFromSuperlayer()
curveLayer = nil
}
curveLayer = CAShapeLayer()
curveLayer?.lineWidth = 1.0/self.zoomScale
curveLayer?.fillColor = UIColor.clear.cgColor
curveLayer?.path = bezierPath.cgPath
curveLayer?.strokeColor = strokeColor.cgColor
viewBase.layer.addSublayer(curveLayer!)
}
我已經儘量把
curveLayer?.borderWidth = 1.0
curveLayer?.borderColor = UIColor.yellow.cgColor
但它沒有畫出邊框(框內)
你能解釋一下PLS代碼? –
我們創建了線寬爲25的lineShapeBorder,因此它作爲邊框,並在lineShapeBorder中添加了線寬爲20的lineShapeFill,因此它充當主層或內層。 –
這裏我的'curveLayer'會是'lineShapeFill'? –