2014-07-25 12:24:17 +08:00
|
|
|
//
|
|
|
|
// ViewController.swift
|
|
|
|
// Snappy
|
|
|
|
//
|
|
|
|
// Created by Jonas Budelmann on 25/07/14.
|
|
|
|
// Copyright (c) 2014 Jonas Budelmann. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
|
|
|
class ViewController: UIViewController {
|
|
|
|
|
|
|
|
override func viewDidLoad() {
|
|
|
|
super.viewDidLoad()
|
|
|
|
|
|
|
|
let superview: UIView = self.view
|
|
|
|
|
2014-07-29 08:39:59 +08:00
|
|
|
let view1 = UIView(frame: CGRectZero)
|
2014-07-25 12:24:17 +08:00
|
|
|
view1.backgroundColor = UIColor.greenColor()
|
|
|
|
view1.layer.borderColor = UIColor.blackColor().CGColor
|
|
|
|
view1.layer.borderWidth = 2
|
|
|
|
superview.addSubview(view1)
|
|
|
|
|
|
|
|
let view2 = UIView()
|
|
|
|
view2.backgroundColor = UIColor.redColor()
|
|
|
|
view2.layer.borderColor = UIColor.blackColor().CGColor
|
|
|
|
view2.layer.borderWidth = 2
|
|
|
|
superview.addSubview(view2)
|
|
|
|
|
|
|
|
let view3 = UIView()
|
|
|
|
view3.backgroundColor = UIColor.blueColor()
|
|
|
|
view3.layer.borderColor = UIColor.blackColor().CGColor
|
|
|
|
view3.layer.borderWidth = 2
|
|
|
|
superview.addSubview(view3)
|
|
|
|
|
2014-07-30 08:55:31 +08:00
|
|
|
let padding = EdgeInsets(top: 15, left: 10, bottom: 15, right: 10)
|
2014-07-25 12:24:17 +08:00
|
|
|
|
2014-07-29 08:39:59 +08:00
|
|
|
|
|
|
|
view1.snp_makeConstraints { make in
|
2014-08-05 09:23:43 +08:00
|
|
|
make.top.and.left.equalTo(superview).insets(padding)
|
2014-07-29 08:39:59 +08:00
|
|
|
make.size.equalTo(CGSizeMake(100, 50))
|
2014-07-27 12:09:38 +08:00
|
|
|
}
|
2014-07-25 12:24:17 +08:00
|
|
|
|
2014-07-29 08:39:59 +08:00
|
|
|
view2.snp_makeConstraints { make in
|
|
|
|
make.centerX.equalTo(view1.snp_centerX).offset(CGPointMake(50, 0))
|
|
|
|
make.top.equalTo(view1.snp_bottom).offset(50)
|
|
|
|
make.width.equalTo(view1.snp_height)
|
|
|
|
make.height.equalTo(view1.snp_width)
|
2014-07-27 12:09:38 +08:00
|
|
|
}
|
2014-07-25 12:24:17 +08:00
|
|
|
|
2014-07-29 08:39:59 +08:00
|
|
|
view3.snp_makeConstraints { make in
|
|
|
|
make.width.height.greaterThanOrEqualTo(view1)
|
|
|
|
make.width.height.greaterThanOrEqualTo(view2)
|
|
|
|
make.center.equalTo(superview)
|
2014-07-27 12:09:38 +08:00
|
|
|
}
|
2014-07-25 12:24:17 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|