1

I have a UISlider from the storyboard in my app. I'd like to change the "track" or bar-looking part to 2x its size and leave the marker/circular part at its current/default size.

Based on this question, they recommended using .transform, which I adapted like so:

    Slider.transform = CGAffineTransform(scaleX: 2.0, y: 2.0)

The output is problematic, as it expands the Slider's marker 2x as well.

enter image description here

I am stuck -- is there a way that I can modify just the track to make it bigger? I have not found a good solution.

I should note that I'd ideally like to use the storyboard element rather than creating an image, if possible. I'd like to do it programmatically.

darkginger
  • 652
  • 1
  • 10
  • 38
  • 1
    Have you looked through the `UISlider` documentation for anything related to the track size? – rob mayoff Mar 21 '18 at 03:55
  • 1
    https://stackoverflow.com/questions/23320179/make-uislider-height-larger?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa Duplicate ? – Tony Nguyen Mar 21 '18 at 04:21
  • @robmayoff: I believe this does not answer. I came across this and receive `Value of type 'UIViewController' has no member 'trackRect'` when I use that code. Believe that does not work for Swift 3, but I am new to this so maybe wrong? – darkginger Mar 21 '18 at 04:35
  • I have a complete answer if this is opened again -- you need to make a class and specify it in the storyboard and then it will run. That is where the answer from your question comes in. – darkginger Mar 21 '18 at 04:41
  • I copied and pasted the code from that answer into a test project and it did exactly what was requested. – rob mayoff Mar 21 '18 at 04:48

0 Answers0