我正在尝试使用BrianCorbin实现的SwiftRangeSlider:
https://github.com/BrianCorbin/SwiftRangeSlider

@IBOutlet weak var labelForRangeSlider: UILabel!

@IBOutlet weak var rangeSlider: RangeSlider!

@IBOutlet weak var submitButton: UIButton!

override func viewDidLayoutSubviews() {
    rangeSlider.updateLayerFrames()
}
...

这表明:

ios - Swift-使用SwiftRangeSlider更新标签-LMLPHP

我要更新“Time”,即labelForRangeSlider,因为rangeSlider的lowerValue和upperValue发生了变化。

最佳答案

您应该为.valueChanged添加事件SwiftRangeSlider的操作:

override func viewDidLoad() {

   super.viewDidLoad()

   let rangeSlider: RangeSlider = RangeSlider(frame: CGRect(x: 0, y: 0, width: 200, height: 60))
   rangeSlider.addTarget(self, action: #selector(self.rangeSliderValueChanged(slider:)), for: UIControlEvents.valueChanged)
   self.view.addSubview(rangeSlider)
}


@IBAction func rangeSliderValueChanged(slider: RangeSlider) {
    print(slider.lowerValue)
}

09-04 06:51