我在一个viewcontroller里面加了如下代码,我用了一个其它的类用协议来传参数给drawOneProgressBar()来画一个子view,但是子view不显示,我试了
view.setNeedsDisplay() view.setNeedsLayout(),都没有用
override func viewDidLoad() {
}
func drawOneProgressBar(a: Int, b: Int) {
if a > b{
drawOneBar()
}else{
print("StartTime is Bigger Than End Time")
}
}
}
func drawOneBar(){
let barRect = UIView(frame: CGRect(x: 0, y: 100, width: 200, height: 50))
view.addSubview(barRect)
barRect.backgroundColor = #colorLiteral(red: 0.2588235438, green: 0.7568627596, blue: 0.9686274529, alpha: 1)
}