let values: [Float] = [15, 30, 50, 70, 85]
for value in values {
guard (slider.minimumValue...slider.maximumValue).contains(value) else { continue }
let label = UILabel()
label.text = "\(value)"
view.addSubview(label)
label.translatesAutoresizingMaskIntoConstraints = false
let thumbRect = slider.thumbRect(forBounds: slider.bounds,
trackRect: slider.trackRect(forBounds: slider.bounds),
value: value)
let convertedThumbRect = slider.convert(thumbRect, to: view)
NSLayoutConstraint.activate([
label.centerXAnchor.constraint(equalTo: view.leadingAnchor, constant: convertedThumbRect.midX),
slider.topAnchor.constraintEqualToSystemSpacingBelow(label.bottomAnchor, multiplier: 1)
])
}