I have a slider and label in my swift project. On the storyboard, I control dragged my slider onto my controller class for that page and created an outlet and also an action
If you want to do it programmatically, this is one way.
var slider: UISlider()
var label: UILabel()
func numberValueChanged(sender: UISlider) {
slider.setValue(Float(Int(slider.value)), animated: true)
updateLabels(slider.value)
}
fun updateLabels(nV: Float?) {
if let v = nV {
self.label.text = "\(v)"
}
}
slider.addTarget (self,
action: #selector(numberValueChanged)
forControlEvents: UIControlEvents.ValueChanged
)
Hope this was helpful :)