2016-08-17 88 views
0

我使用UICeizerPath与roundedRect和CAShaplayer附加到我的UIView。我已经评论了填充,但它仍然填充矩形。Swift:UIBeizerPath CAShapelayer填充时填充注释

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

我猜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) 

感谢您的帮助

回答

1

设置fillColornil

shapeLayer.fillColor = nil 
+0

谢谢! –

1

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

- fillColor属性的文件。

+0

错过了那一个。谢谢! –

+0

@NicholasMuir欢迎您。你不是第一个遇到这个问题的人。我从我的错误中学到:P – Tricertops