Nicholas Muir Nicholas Muir - 2 months ago 4x
Swift Question

Swift: UIBeizerPath CAShapelayer filling when fill commented

I am using UIBeizerPath with roundedRect and a CAShaplayer to attach to my UIView. I have commented out the filling but it is still filling the rectangle.

All I am trying to do is have the rounded rectangular line around the outside.

I am guessing that roundedRect is a solid and I may have to use the UIBeizerPath or fill with clear but I have not been able to find documentation.

This is my code:

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

Thanks for your help


Set fillColor to nil.

shapeLayer.fillColor = nil