subjective-c
subjective-c

Reputation: 1823

Customizing UISlider appearance

I want to set the thumb image of a slider for a normal state, but still use the default track images.

So i do this:

[theSlider setThumbImage:[UIImage imageNamed:@"my_thumb.png"] 
forState: UIControlStateNormal];

and I get my image appear as thumb, but then default track images disappear.

Can't you just customize the thumb image and leave the track images default?

Upvotes: 1

Views: 2341

Answers (2)

IllyaB
IllyaB

Reputation:

When you are creating your UISlider, whether it be in Interface Builder or progmatically be sure to set the Continuous variable to YES. (ie. [mySlider setContinuous:YES]). After this variable is set, you should be able to use your own thumb images.

Upvotes: 0

pix0r
pix0r

Reputation: 31280

It doesn't seem like this is possible, strangely.

As a workaround, you have a couple choices. It shouldn't be too difficult to screenshot and extract the necessary graphics to create your own nearly-identical min and max track images. You'll need to get the rounded edges and a couple pixels of the flat part which will be stretched.

Alternately, you could try to extract the actual images using this technique: Extract UIKit artwork

Personally, I don't see why you can't mix and match custom graphics with default graphics, but this seems to be how Apple implemented this control.

Upvotes: 2

Related Questions