代码如下:
let page = UIView()
page.frame = self.view.bounds
//直接设置颜色
page.backgroundColor = UIColor.greenColor()
//设置16进制的颜色
page.backgroundColor = UIColor(red: 0x37/, green: 0xba/, blue: 0x46/, alpha: )
//设置背景图片(如果图片太小,会自动平铺)
page.backgroundColor = UIColor.init(patternImage: UIImage(named: "11.jpg")!) self.view.addSubview(page)