How do you use Interface builder with Swift?

后端 未结 5 1596
日久生厌
日久生厌 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:38

    Below code shows IBOutlet and IBAction format in Swift :

    class MyViewController: UIViewController {
    
      @IBOutlet weak var btnSomeButton: UIButton?
      @IBOutlet weak var lblLabelItem: UILabel?
    
      @IBAction func btnSomeButtonClicked(sender: UIButton) {
        ...
      }
    }
    

    You can bind them same way as done in Objective-C.

提交回复
热议问题