1、使用UIColor的内置颜色设置背景色
let page = UIView(frame: self.view.bounds)
page.backgroundColor = .green
2、设置自定义颜色
page.backgroundColor = UIColor(red: 0x37/255, green: 0xba/255, blue: 0x46/255, alpha: 1)
3、设置背景图片(如果图片太小,会自动平铺)
page.backgroundColor = UIColor(patternImage: UIImage(named:"bg1.png")!)
网友评论