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
非常感謝!但這是一箇舊版本,我目前正在研究看起來好多了的新版本,我認爲!你是怎麼找到它的? –