-
-
Save jplazcano87/29c448548ab45fe8de0c62226038b4b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import XCPlayground | |
class ViewController: UIViewController { | |
func action() { print("Bing!") } | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
view.backgroundColor = .whiteColor() | |
let mySwitch : UISwitch = { | |
view.addSubview($0) | |
CenterViewInSuperview($0, | |
horizontal: true, vertical: true) | |
$0.addTarget(self, action: "action", | |
forControlEvents: .TouchUpInside) | |
return $0 | |
}(UISwitch()) | |
let _ : UILabel = { | |
view.addSubview($0) | |
CenterViewInSuperview($0, | |
horizontal: true, vertical: false) | |
$0.text = "Toggle me" | |
$0.font = UIFont.boldSystemFontOfSize(36) | |
ConstrainViews("V:[view1]-30-[view2]", | |
views: $0, mySwitch) | |
return $0 | |
}(UILabel()) | |
} | |
} | |
ViewController() | |
XCPlaygroundPage.currentPage.liveView = ViewController() | |
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment