【发布时间】:2016-10-13 05:17:09
【问题描述】:
我想用我的自定义颜色填充UIBezierPath,但只有UIColor.redColor 或UIColor.blueColor 等默认颜色有效。
这是我的代码:
override func drawRect(rect: CGRect) {
let layerHeight = self.layer.frame.height
let layerWidth = self.layer.frame.width
let width:CGFloat = 50
let bezierPath = UIBezierPath()
bezierPath.moveToPoint(CGPointMake(layerWidth, layerHeight))
bezierPath.addLineToPoint(CGPointMake(layerWidth, layerHeight - width))
bezierPath.addLineToPoint(CGPointMake(layerWidth - width, layerHeight))
bezierPath.closePath()
// UIColor.blueColor().setFill() works, but a custom color does not:
UIColor(colorLiteralRed: 23, green: 34, blue: 200, alpha: 1).setFill()
bezierPath.fill()
}
【问题讨论】: