How do you use Interface builder with Swift?

后端 未结 5 1595
日久生厌
日久生厌 2021-02-07 12:11

When hooking Swift code up to a Storyboard, how do you add the IBAction and IBOutlet tags?

5条回答
  •  既然无缘
    2021-02-07 12:47

    Add IBAction and IBOutlet attributes to variables and functions so they can be visible in Interface builder.

    class ViewController: UIViewController {
    
        @IBOutlet var label: UILabel?
    
        @IBAction func doTap(x:UIButton) {
            println("Tapped: \(x)")
        }
    }
    

提交回复
热议问题