#2 從程式製作國旗圖案
Published in
Jan 28, 2021
一開始先用Playground練習繪製簡單的國旗圖
用addSubview把每一層的顏色加上去
import UIKitvar rect = CGRect(x: 0, y: 0, width: 511, height: 276)
let blueBackgroundView = UIView(frame: rect)
blueBackgroundView.backgroundColor = UIColor(displayP3Red: 0, green: 34/255, blue: 149/255, alpha: 1)rect = CGRect(x: 170, y: 0, width: 340, height: 276)
let whiteView = UIView(frame: rect)
whiteView.backgroundColor = UIColor(red: 1, green: 1, blue: 1, alpha: 1)blueBackgroundView.addSubview(whiteView)rect = CGRect(x: 342, y: 0, width: 170, height: 276)
let redView = UIView(frame: rect)
redView.backgroundColor = UIColor(red: 237/255, green: 41/255, blue: 57/255, alpha: 1)blueBackgroundView.addSubview(redView)
blueBackgroundView