Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create an iPod-esque UISlider

Does anyone have a quick way to make a UISlider that looks like the ones in the iPod app (think scrubber/volume control). Basically I need something that looks exactly like an MPVolumeView, but doesn't control sound. Failing that, does anyone have the assets to make one (the knob/track).

like image 278
Max Avatar asked Aug 15 '09 00:08

Max


People also ask

What is UISlider?

A UISlider object is used for selecting a single value from a continuous range of values. The value is decreased or increased as the user moves the “thumb” of the slider along its track.


1 Answers

Yeah, I knew how to create the custom slider, I just wanted to know if anyone had the images already. I guess not, so I extracted my own.

For future reference, if anyone else needs to do this:

Gallery of assets below, http://img200.imageshack.us/gal.php?g=whiteslide.png

Download those images, and use this code to set it all up:

scrubberSlider.backgroundColor = [UIColor clearColor];  
UIImage *stetchLeftTrack = [[UIImage imageNamed:@"blueTrack.png"]
                            stretchableImageWithLeftCapWidth:9.0 topCapHeight:0.0];
UIImage *stetchRightTrack = [[UIImage imageNamed:@"whiteTrack.png"]
                             stretchableImageWithLeftCapWidth:9.0 topCapHeight:0.0];
[scrubberSlider setThumbImage: [UIImage imageNamed:@"whiteSlide.png"] forState:UIControlStateNormal];
[scrubberSlider setMinimumTrackImage:stetchLeftTrack forState:UIControlStateNormal];
[scrubberSlider setMaximumTrackImage:stetchRightTrack forState:UIControlStateNormal];
like image 182
Max Avatar answered Sep 18 '22 17:09

Max