DividerDemoVC.swift 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // DividerDemoVC.swift
  3. // KMComponentLibraryDemo
  4. //
  5. // Created by wanjun on 2024/8/1.
  6. //
  7. import Cocoa
  8. import KMComponentLibrary
  9. class DividerDemoVC: NSViewController {
  10. @IBOutlet weak var dividerView: ComponentDivider!
  11. @IBOutlet weak var width_layout: NSLayoutConstraint!
  12. @IBOutlet weak var height_layout: NSLayoutConstraint!
  13. @IBOutlet weak var typeComboBox: NSComboBox!
  14. @IBOutlet weak var dashButton: NSButton!
  15. let properties_Divider: ComponentDividerProperty = ComponentDividerProperty.init(type: .horizontal, dash: false)
  16. override func viewDidLoad() {
  17. super.viewDidLoad()
  18. // Do view setup here.
  19. width_layout.constant = 100.0
  20. height_layout.constant = 1.0
  21. self.reloadData()
  22. }
  23. func reloadData() {
  24. if self.typeComboBox.indexOfSelectedItem == 0 {
  25. typeComboBox.stringValue = "horizontal"
  26. width_layout.constant = 100.0
  27. height_layout.constant = 1
  28. properties_Divider.type = .horizontal
  29. } else if self.typeComboBox.indexOfSelectedItem == 1 {
  30. typeComboBox.stringValue = "vertical"
  31. width_layout.constant = 1.0
  32. height_layout.constant = 100.0
  33. properties_Divider.type = .vertical
  34. }
  35. if dashButton.state == .off {
  36. properties_Divider.dash = false
  37. } else {
  38. properties_Divider.dash = true
  39. }
  40. self.dividerView.properties = properties_Divider
  41. }
  42. // MARK: Action
  43. @IBAction func typeAction(_ sender: NSComboBox) {
  44. self.reloadData()
  45. }
  46. @IBAction func dashAction(_ sender: NSButton) {
  47. self.reloadData()
  48. }
  49. }