【发布时间】:2016-01-15 19:40:24
【问题描述】:
我创建了一个新的子视图类来进行绘图 我已经覆盖了函数 drawRect() 但我无法更改 子视图的背景颜色我使用了背景方法,但它不起作用!
import UIKit
class AbedView:UIView {
override func drawRect(rect: CGRect) {
let color = UIColor.blueColor()
// Do any additional setup after loading the view, typically from a nib.
let cgrRect = CGRect(x: 0, y: 0, width: 100, height: 100)
let newView = UIBezierPath(rect: cgrRect)
print(newView.bounds)
color.set()
newView.lineWidth = 5
newView.stroke()
self.backgroundColor = UIColor.blackColor()
}
}
【问题讨论】:
标签: swift colors background