Swift:填充注释时填充UIBeizerPath CAShapelayer

时间:2016-08-17 07:06:33

标签: ios swift uibezierpath rounded-corners cashapelayer

我正在使用带有roundedRect的UIBeizerPath和一个附加到我的UIView的CAShaplayer。我已经注释了填充物,但它仍然填充了矩形。

我要做的就是在外面有圆角矩形线。

我猜测roundRect是一个固体,我可能不得不使用UIBeizerPath或填写清楚但我无法找到文档。

这是我的代码:

    let rect: CGRect = frontview.bounds
    var shape: UIBezierPath = UIBezierPath(roundedRect: rect, cornerRadius: 5.0)
    var shapeLayer = CAShapeLayer()
    shapeLayer.path = shape.CGPath
    //shapeLayer.fillColor = UIColor(red: 0.5, green: 1, blue: 0.5, alpha: 1).CGColor
    shapeLayer.strokeColor = UIColor.blackColor().CGColor
    shapeLayer.lineWidth = 2
    self.frontview.layer.addSublayer(shapeLayer)

感谢您的帮助

2 个答案:

答案 0 :(得分:1)

fillColor设为nil

shapeLayer.fillColor = nil

答案 1 :(得分:1)

“默认为不透明的黑色。”

- fillColor属性的文档。