Changing UISlider Images with Swift

Changing UISlider thumb image with Swift

yourSlider.setThumbImage(UIImage(named: "yourSlider.png"), forState: UIControlState.Normal)

    yourSlider.setThumbImage(UIImage(named: "yourSlider.png"), forState: UIControlState.Highlighted)

From Doc Example

let leftTrackImage = UIImage(named: "slider_blue_track")
customslider.setMinimumTrackImage(leftTrackImage, for: .normal)

SWIFT 3

class Slider: UISlider {

    @IBInspectable var thumbImage: UIImage?

    // MARK: Lifecycle

    override func awakeFromNib() {
        super.awakeFromNib()

        if let thumbImage = thumbImage {
            self.setThumbImage(thumbImage, for: .normal)
        }
    }
}

Tags:

Ios

Xcode

Swift