1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- //
- // DividerDemoVC.swift
- // KMComponentLibraryDemo
- //
- // Created by wanjun on 2024/8/1.
- //
- import Cocoa
- import KMComponentLibrary
- class DividerDemoVC: NSViewController {
-
- @IBOutlet weak var dividerView: ComponentDivider!
-
- @IBOutlet weak var width_layout: NSLayoutConstraint!
- @IBOutlet weak var height_layout: NSLayoutConstraint!
-
- @IBOutlet weak var typeComboBox: NSComboBox!
- @IBOutlet weak var dashButton: NSButton!
- let properties_Divider: ComponentDividerProperty = ComponentDividerProperty.init(type: .horizontal, dash: false)
- override func viewDidLoad() {
- super.viewDidLoad()
- // Do view setup here.
-
- width_layout.constant = 100.0
- height_layout.constant = 1.0
-
- self.reloadData()
- }
-
- func reloadData() {
- if self.typeComboBox.indexOfSelectedItem == 0 {
- typeComboBox.stringValue = "horizontal"
- width_layout.constant = 100.0
- height_layout.constant = 1
-
- properties_Divider.type = .horizontal
- } else if self.typeComboBox.indexOfSelectedItem == 1 {
- typeComboBox.stringValue = "vertical"
- width_layout.constant = 1.0
- height_layout.constant = 100.0
- properties_Divider.type = .vertical
- }
- if dashButton.state == .off {
- properties_Divider.dash = false
- } else {
- properties_Divider.dash = true
- }
-
- self.dividerView.properties = properties_Divider
-
- }
-
- // MARK: Action
-
- @IBAction func typeAction(_ sender: NSComboBox) {
- self.reloadData()
- }
-
-
- @IBAction func dashAction(_ sender: NSButton) {
- self.reloadData()
- }
-
- }
|