AshishVerma AshishVerma - 4 months ago 56
iOS Question

How can I change font from system to custom in UI slider. Swift 3

How can i change font from system to custom in ui slider element. I want to change system front to - Custom font (Bodoni 72 Book), How can i do that?

My code -

@IBAction func UISlider(_ sender: UISlider) {
print("Slider value \(UISlider.value)")

self.UILable.font = UIFont.systemFont(ofSize: CGFloat(UISlider.value * 72.0))


Problem - When use the slider it changes the custom font to system font.


Look at your code, you are assigning UIFont.systemFont(... to the font property of the label.

I changed UILable to sliderLabel

You need:

self.sliderLabel.font = UIFont(name: someFontFamilyName, size: CGFloat(UISlider.value * 72.0))