iOS之UIView的基本使用(Swift 4.2)
阿新 • • 發佈:2018-12-11
override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. let rect1 = CGRect(x: 30, y: 50, width: 200, height: 200) let view1 = UIView(frame: rect1) view1.backgroundColor = UIColor.brown let rect2 = CGRect(x: 90, y: 120, width: 200, height: 200) let view2 = UIView(frame: rect2) view2.backgroundColor = UIColor.purple self.view.addSubview(view1) self.view.addSubview(view2)