swiftuibezierpathbacktracensbezierpath

Can't display an UIBezierPath


I'm trying to display an UIBezierPath in a view. That's the object:

let color = UIColor(red: 0.651, green: 1.000, blue: 0.000, alpha: 1.000).setFill() 
let rectanglePath = UIBezierPath(rect: CGRectMake(15, 0, 8, 120))
rectanglePath.fill()

but, when run, xCode displays just a lot messages in console and none in the simulator!

I tried following these solutions How can I set CG_CONTEXT_SHOW_BACKTRACE environmental variable? but is the same (and, in their opinion, issue should be solved in with iOS 9.1).

Here's an example code.


Solution

  • Just change the code:

        let shapeLayer = CAShapeLayer()
        let color = UIColor(red: 0.651, green: 1.000, blue: 0.000, alpha: 1.000).CGColor
        let rectanglePath = UIBezierPath(rect: CGRectMake(15, 0, 8, 120))
    
        shapeLayer.path = rectanglePath
        shapeLayer.fillColor = color
    
        self.view.layer.addSublayer(shapeLayer)