Created
April 3, 2016 11:07
-
-
Save keitaito/c6935572744da7b3e499dfcd61ed3800 to your computer and use it in GitHub Desktop.
Code snippet for Interactive Playground
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
//: Playground - noun: a place where people can play | |
import UIKit | |
import XCPlayground | |
class SomeView: UIView { | |
override init(frame: CGRect) { | |
super.init(frame: frame) | |
let button = UIButton(frame: self.bounds) | |
button.backgroundColor = UIColor.whiteColor() | |
self.addSubview(button) | |
button.addTarget(self, action: #selector(buttonTapped), forControlEvents: .TouchUpInside) | |
let label = UILabel(frame: CGRectMake(20, 20, 20, 20)) | |
label.text = "Tap here" | |
label.sizeToFit() | |
label.center = button.center | |
button.addSubview(label) | |
} | |
required init?(coder aDecoder: NSCoder) { | |
fatalError("init(coder:) has not been implemented") | |
} | |
func buttonTapped() { | |
print("button tapped") | |
} | |
} | |
XCPlaygroundPage.currentPage.liveView = SomeView(frame: UIScreen.mainScreen().bounds) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/keitaito/TestInteractivePlayground