如何在Swift中使用Interface builder?

Jas*_*ore 14 interface-builder xcode-storyboard swift

将Swift代码挂钩到Storyboard时,如何添加IBActionIBOutlet标记?

Jas*_*ore 31

添加IBActionIBOutlet属性到变量和函数,以便它们可以在"界面"构建器中可见.

class ViewController: UIViewController {

    @IBOutlet var label: UILabel?

    @IBAction func doTap(x:UIButton) {
        println("Tapped: \(x)")
    }
}
Run Code Online (Sandbox Code Playgroud)

  • 如果你正在开发自己的控件,你也可以使用`@ IBDesignable`和`@ IBInspectable`.:) (3认同)