Remove unneeded closure ornamentation

This commit is contained in:
Elvis Nuñez 2016-05-12 10:55:55 +02:00
parent c0d8a7d3e8
commit 6f5b8c4e55
1 changed files with 27 additions and 27 deletions

View File

@ -11,87 +11,87 @@ import UIKit
class SimpleLayoutViewController: UIViewController { class SimpleLayoutViewController: UIViewController {
var didSetupConstraints = false var didSetupConstraints = false
let blackView: UIView = { let blackView: UIView = {
let view = UIView() let view = UIView()
view.backgroundColor = .blackColor() view.backgroundColor = .blackColor()
return view return view
}() }()
let redView: UIView = { let redView: UIView = {
let view = UIView() let view = UIView()
view.backgroundColor = .redColor() view.backgroundColor = .redColor()
return view return view
}() }()
let yellowView: UIView = { let yellowView: UIView = {
let view = UIView() let view = UIView()
view.backgroundColor = .yellowColor() view.backgroundColor = .yellowColor()
return view return view
}() }()
let blueView: UIView = { let blueView: UIView = {
let view = UIView() let view = UIView()
view.backgroundColor = .blueColor() view.backgroundColor = .blueColor()
return view return view
}() }()
let greenView: UIView = { let greenView: UIView = {
let view = UIView() let view = UIView()
view.backgroundColor = .greenColor() view.backgroundColor = .greenColor()
return view return view
}() }()
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = UIColor.whiteColor() view.backgroundColor = UIColor.whiteColor()
view.addSubview(blackView) view.addSubview(blackView)
view.addSubview(redView) view.addSubview(redView)
view.addSubview(yellowView) view.addSubview(yellowView)
view.addSubview(blueView) view.addSubview(blueView)
view.addSubview(greenView) view.addSubview(greenView)
view.setNeedsUpdateConstraints() view.setNeedsUpdateConstraints()
} }
override func updateViewConstraints() { override func updateViewConstraints() {
if (!didSetupConstraints) { if (!didSetupConstraints) {
blackView.snp_makeConstraints(closure: { (make) -> Void in blackView.snp_makeConstraints { make in
make.center.equalTo(view) make.center.equalTo(view)
make.size.equalTo(CGSizeMake(100.0, 100.0)) make.size.equalTo(CGSizeMake(100.0, 100.0))
}) }
redView.snp_makeConstraints(closure: { (make) -> Void in redView.snp_makeConstraints { make in
make.top.equalTo(blackView.snp_bottom).offset(20.0) make.top.equalTo(blackView.snp_bottom).offset(20.0)
make.left.equalTo(20.0) make.left.equalTo(20.0)
make.size.equalTo(CGSizeMake(100.0, 100.0)) make.size.equalTo(CGSizeMake(100.0, 100.0))
}) }
yellowView.snp_makeConstraints(closure: { (make) -> Void in yellowView.snp_makeConstraints { make in
make.top.equalTo(blackView.snp_bottom).offset(20.0) make.top.equalTo(blackView.snp_bottom).offset(20.0)
make.left.equalTo(blackView.snp_right).offset(20.0) make.left.equalTo(blackView.snp_right).offset(20.0)
make.size.equalTo(CGSizeMake(100.0, 100.0)) make.size.equalTo(CGSizeMake(100.0, 100.0))
}) }
blueView.snp_makeConstraints(closure: { (make) -> Void in blueView.snp_makeConstraints { make in
make.bottom.equalTo(blackView.snp_top).offset(-20.0) make.bottom.equalTo(blackView.snp_top).offset(-20.0)
make.left.equalTo(blackView.snp_right).offset(20.0) make.left.equalTo(blackView.snp_right).offset(20.0)
make.size.equalTo(CGSizeMake(100.0, 100.0)) make.size.equalTo(CGSizeMake(100.0, 100.0))
}) }
greenView.snp_makeConstraints(closure: { (make) -> Void in greenView.snp_makeConstraints { make in
make.bottom.equalTo(blackView.snp_top).offset(-20.0) make.bottom.equalTo(blackView.snp_top).offset(-20.0)
make.right.equalTo(blackView.snp_left).offset(-20.0) make.right.equalTo(blackView.snp_left).offset(-20.0)
make.size.equalTo(CGSizeMake(100.0, 100.0)) make.size.equalTo(CGSizeMake(100.0, 100.0))
}) }
didSetupConstraints = true didSetupConstraints = true
} }
super.updateViewConstraints() super.updateViewConstraints()
} }