Skip to content

Instantly share code, notes, and snippets.

@kennylugo
Last active January 16, 2016 00:49
Show Gist options
  • Select an option

  • Save kennylugo/26edf261833db567641a to your computer and use it in GitHub Desktop.

Select an option

Save kennylugo/26edf261833db567641a to your computer and use it in GitHub Desktop.
ProgramaticButton
override func viewDidLoad() {
super.viewDidLoad()
let button = UIButton(type: UIButtonType.System) as UIButton
button.frame = CGRectMake(100, 100, 100, 100)
button.backgroundColor = UIColor.redColor()
button.setTitle("Touch for a hello greeting", forState: .Normal)
self.view.addSubview(button)
}
// 1: Define button instance
// 2: Set it's frame
// 3: Set it's background color
// 4: set the title
// 5: Add it to the subview
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment