3CC
3CC

Reputation: 502

UISlider track visual issues

I changed thumb image for UISlider. Now I have 2 visual issues:

  1. Track does not start at the beginning of the slider
  2. Track is not visible for the first 10-20px, than it appears filling the empty space behind

Here are 3 positions of the same slider:

enter image description here

Upvotes: 1

Views: 309

Answers (1)

Earl Grey
Earl Grey

Reputation: 7466

I think the problem is with the size of the pointerImage that probably contains some alpha on sides. Please verify that the pointer image is only 2-3 points wide.

Plus I see some artefact on the tracker image, it is probably not made correctly resizable via resizableImageWithCapInsets: method. that cause its leading end to be deformed.

Here's code that works and does exactly what you want without any glitches:

[self.slider setThumbImage:[UIImage imageNamed:@"slider"] forState:UIControlStateNormal];

[self.slider setMinimumTrackTintColor:[UIColor darkGrayColor]];

Obviously the @"slider" being the name of the point image in Xcode image assets. And you can put any color there , you don't have to use the built-in dark gray.

Upvotes: 1

Related Questions