// // SegmentedVC.swift // KMComponentLibrary // // Created by Niehaoyu on 2024/9/9. // import Cocoa import KMComponentLibrary class SegmentedVC: NSViewController { @IBOutlet weak var segmented: ComponentSegmented! @IBOutlet weak var sizeBox: NSComboBox! @IBOutlet weak var countBox: NSComboBox! @IBOutlet weak var segmentedheightConst: NSLayoutConstraint! override func viewDidLoad() { super.viewDidLoad() // Do view setup here. self.reloadData() } func reloadData() { var size: ComponentSize = .m self.segmentedheightConst.constant = 32 if self.sizeBox.indexOfSelectedItem == 1 { size = .s self.segmentedheightConst.constant = 24 } var count = 2 if self.countBox.indexOfSelectedItem == 0 { count = 2 } else if self.countBox.indexOfSelectedItem == 1 { count = 3 } else if self.countBox.indexOfSelectedItem == 2 { count = 4 } var itemArr: [ComponentSegmentedProperty] = [] for i in 0...count-1 { let property = ComponentSegmentedProperty(size: size, active: false, iconImage: NSImage(named: ""), iconImage_active: NSImage(named: "")) if i == 0 { property.active = true } itemArr.append(property) } self.segmented.updateItemProperty(itemArr) } @IBAction func boxAction(_ sender: Any) { self.reloadData() } }