How to change the size of a UISlider thumb when seeking
Asked Answered
G

1

6

I'd like to make my UISlider thumb size change while I scrub the slider, much like how the seeker works in Apple Music or Spotify. Is this possible to do with a vanilla UISlider? Any pointers on how to do this would be much appreciated. Thanks

Gnotobiotics answered 5/7, 2020 at 23:56 Comment(0)
T
6

Create a normal and larger thumb image with the sizes you want as PDF and add it to the .xcassets.

Then use the following lines of code:

let normal = UIImage(named: "thumbSmall")
slider.setThumbImage(normal, for: .normal)
let highlighted = UIImage(named: "thumbLarger")
slider.setThumbImage(highlighted, for: .highlighted)

Then during sliding the larger thumb image is shown.

A short test looks like this:

thumb size during sliging

Terminator answered 13/8, 2020 at 7:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.