我正在尝试使用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()
}
...
这表明:
我要更新“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)
}