Objective-c – Hide UISlider thumb image

iphoneobjective cuislider

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];

Best Answer

Much simpler:

Objc

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

Swift version

sli.setThumbImage(UIImage(), for: .normal)
Related Topic