Swift - 设置UIView的背景色和背景图片
1,使用UIColor的内置颜色设置背景色
1
2
|
var page = UIView () page.backgroundColor = UIColor .greenColor() |
2,设置自定义颜色
1
|
page.backgroundColor = UIColor (red: 0x37/255, green: 0xba/255, blue: 0x46/255, alpha: 1) |
3,设置背景图片(如果图片太小,会自动平铺)
1
|
page.backgroundColor = UIColor (patternImage: UIImage (named: "bg1.png" )!) |