For create UIButton from storyboard: 1 - Drag UIButton object from Object Library to ViewController in storyboard file 2 - Show Assistant editor 3 - Drag with right click from UIButton create above into your class. The result is the following:
@IBAction func buttonActionFromStoryboard(sender: UIButton)
{
println("Button Action From Storyboard")
}
For create UIButton programmatically: 1- Write into "override func viewDidLoad()":
let uiButton = UIButton.buttonWithType(UIButtonType.System) as UIButton
uiButton.frame = CGRectMake(16, 116, 288, 30)
uiButton.setTitle("Second", forState: UIControlState.Normal);
uiButton.addTarget(self, action: "buttonActionFromCode:", forControlEvents: UIControlEvents.TouchUpInside)
self.view.addSubview(uiButton)
2- add the IBAction func:
@IBAction func buttonActionFromCode(sender:UIButton)
{
println("Button Action From Code")
}