Uislider Setmaximumtracktintcolor in iOS 7.1

UISlider setMaximumTrackTintColor in iOS 7.1

Found this workaroud:

Create a 1x1px UIImage from a UIColor on the fly:

CGRect rect = CGRectMake(0, 0, 1, 1);
UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0);
[color setFill];
UIRectFill(rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

and then

[slider setMaximumTrackImage:image forState:UIControlStateNormal];

Looks like an expensive solution but it gets the job done.

UISlider minimum and maximum track tint clear color iOS 7.1 bug

Okay so I solved this already by using these two lines of code replacing the trackTintColor properties altogether:

[self.colorSlider setMinimumTrackImage:[UIImage new] forState:UIControlStateNormal];
[self.colorSlider setMaximumTrackImage:[UIImage new] forState:UIControlStateNormal];

UISlider with single bar color

set

choice -1

yoursliderName.minimumTrackTintColor = [UIColor blueColor];
yoursliderName.maximumTrackTintColor = [UIColor blueColor];

if choice no 1 is not work

choice - 2

see this already answered in stack overflow answer

additional Reference

Unable to set UISlider's track tint to absolute clearColor

You can try this:

UIGraphicsBeginImageContextWithOptions((CGSize){ 1, 1 }, NO, 0.0f);
UIImage *transparentImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

[self.seekBar setMinimumTrackImage:transparentImage forState:UIControlStateNormal];
[self.seekBar setMaximumTrackImage:transparentImage forState:UIControlStateNormal];
[self.seekBar setTintColor:[UIColor clearColor]];

Hope it helps :)



Related Topics



Leave a reply



Submit