无法显示 UIBezierPath

Can't display an UIBezierPath

我正在尝试在视图中显示 UIBezierPath。那就是对象:

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()

但是,当 运行 时,xCode 仅在控制台中显示大量消息,而在模拟器中显示 none!

我尝试遵循这些解决方案 但结果是一样的(而且,在他们看来,问题应该在 iOS 9.1 中解决)。

Here's an example 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)