How to customise UISlider height

Nik picture Nik · Jul 23, 2015 · Viewed 21.7k times · Source

I have project in which have to customise UISlider element. I wondering if someone knows how to change, or is it possible to change height of UISlide bar line.

I tried something like this but don't work:

let customBounds = CGRect(origin: bounds.origin, 
                          size: CGSize(width: bounds.size.width, height: 15.0))
feedbackSlider.trackRectForBounds(customBounds)

Thanks

Answer

Learn Swift picture Learn Swift · Aug 24, 2016

i hope that you want edit it in storyboard, and only the line size, use it in your custom UISlider

class CustomSlide: UISlider {

     @IBInspectable var trackHeight: CGFloat = 2

     override func trackRectForBounds(bounds: CGRect) -> CGRect {
         //set your bounds here
         return CGRect(origin: bounds.origin, size: CGSizeMake(bounds.width, trackHeight))



       }
}