Search code examples
iosuislider

Change alpha of UISlider's track image?


Is there any way to change the alpha of a UISlider's track image? I want to use documented API's so my app can get on the app store.I am using apple's default track image and NOT my own. Is this possible?

Thanks!


Solution

  • You can obtain the slider's track images using the currentMaximumTrackImage and currentMinimumTrackImage properties. You can then adjust the alpha on these images but this is quite tedious to do with code as you'd have to set up a context, draw the image with the alpha, then obtain the new image from the context. Note that you would have to do this for the minimum and maximum track images for each applicable state of the control.

    Can't you set the alpha on the whole slider, or do you just want the track to have an alpha rather than the whole control?