Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide UISlider thumb image

I am trying to create a UISlider without the thumb image.

How can I do this, this is my code so far:

UISlider *sli = [[UISlider alloc] initWithFrame:progressView.frame];     [sli setThumbImage:nil forState:UIControlStateNormal];     [sli setBackgroundColor:[UIColor clearColor]];      [sli setMinimumTrackImage:[[UIImage imageNamed:@"ProgressBlueCap.png"] stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0] forState:UIControlStateNormal];     [sli setMaximumTrackImage:[[UIImage imageNamed:@"ProgressBlueCapRight.png"] stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0] forState:UIControlStateNormal]; 
like image 548
max_ Avatar asked Apr 22 '11 16:04

max_


2 Answers

Much simpler:

Objc

[sli setThumbImage:[[[UIImage alloc] init] autorelease] forState:UIControlStateNormal]; 

Swift version

sli.setThumbImage(UIImage(), for: .normal) 
like image 161
jakeboxer Avatar answered Sep 25 '22 15:09

jakeboxer


The easiest way is simply setting the Thumb Tint colour to Clear on the Interface Builder - like so...

enter image description here

Voila!

like image 39
Jim Tierney Avatar answered Sep 22 '22 15:09

Jim Tierney