supeview VS subViews(父視圖 VS 子視圖)
class ViewController: UIViewController {
@IBOutlet weak var midRect: UIView!
//midRect型別為optional UIView
透過StoryBoard或程式碼來調整UIView各項設定
.backgroundColor屬性:調整UIView的顏色
midRect.backgroundColor = UIColor.green
.alpha屬性:調整UIView的透明度(0~1)
midRect.alpha = 0.5
.isHidden屬性:隱藏UIView(true/false)
midRect.isHidden = true
設定整個View(畫面)的底色
self.view.backgroundColor = UIColor.orange
//self可省略:view.backgroundColor = UIColor.orange
設定自定義顏色
self.view.backgroundColor = UIColor.init(red: 1, green: 0.9, blue: 0.8, alpha: 1)
使用tag屬性替UIView編號
self.view.viewWithTag(101)?.backgroundColor = UIColor.lightGray
//self省略:view.viewWithTag(101)?.backgroundColor = lightGray