0
我想用我的自定义颜色填充UIBezierPath
,但只有默认颜色(如UIColor.redColor
或UIColor.blueColor
)正在工作。为什么我不能用自定义UIColor填充UIBezierPath?
这里是我的代码:
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()
}
哦,我的上帝太尴尬,但谢谢你:) –
@JulianPomper恭喜你的应用程序顺便说一句,看起来非常整齐,设计很好! – luk2302
非常感谢!但这是一个旧版本,我目前正在研究看起来好多了的新版本,我认为!你是怎么找到它的? –