Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make UISlider's "track" invisible?

Tags:

I'm trying to emulate Apple's "Slide to Unlock" feature in my application. I get to this point (image below), but as you can see the UISlider's "track" is visible and is covering up my text. Is there a way to change an attribute programmatically that will make the "track" invisible?

alt text

Please let me know if you need any of my code.

Thanks in advance!

EDIT: If I change the slider's alpha to 0, it gets rid of my sliding button, so doing that won't work unless I'm doing it wrong. :)

like image 690
sudo rm -rf Avatar asked Nov 11 '10 02:11

sudo rm -rf


2 Answers

here's an even easier way. No need to create images, just instantiate an empty UIImage class :P

UIImage *clearImage = [[UIImage alloc] init];
[self.slider setMinimumTrackImage:clearImage forState:UIControlStateNormal];
[self.slider setMaximumTrackImage:clearImage forState:UIControlStateNormal];
like image 147
Alex the Ukrainian Avatar answered Sep 22 '22 07:09

Alex the Ukrainian


Actually I just figured it out. Here's what I did:

UIImage *sliderMinimum = [[UIImage imageNamed:@"clearTrack.png"] stretchableImageWithLeftCapWidth:4 topCapHeight:0];
[slider setMinimumTrackImage:sliderMinimum forState:UIControlStateNormal];
UIImage *sliderMaximum = [[UIImage imageNamed:@"clearTrack.png"] stretchableImageWithLeftCapWidth:4 topCapHeight:0];
[slider setMaximumTrackImage:sliderMaximum forState:UIControlStateNormal];

clearTrack.png is just a clear slider image I made.

Now I have this: yay! alt text

like image 44
sudo rm -rf Avatar answered Sep 23 '22 07:09

sudo rm -rf