Split View

xib-based

Drag NSSplitView control to xib interface from control libraries, change control custom class to component class name of your exported.


code-based

Declare lazy load variable in the controller class and add it to the view.

import Cocoa
class ViewController: NSViewController {
    lazy var splitView: HDSplitView = {
        let splitView = HDSplitView(frame: NSRect(x: 100, y: 100, width: 200, height: 200))
        return splitView
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.addSubview(splitView)
    }

}

重要提示:

HDSplitView 类中使用了HDColorView类, 这个需要先创建一个View视图控件来生成.