开发者

How to remove blue shading on left side of a UISlider control?

开发者 https://www.devze.com 2023-03-13 15:20 出处:网络
Is there a way to easily remove the blue shading from the left side 开发者_开发问答of a UISlider control or do I need to use a custom graphic?

Is there a way to easily remove the blue shading from the left side 开发者_开发问答of a UISlider control or do I need to use a custom graphic?

Many thanks


Depends on what you mean by "easily". If you mean as in setting a property on the UISlider object then I think the answer is no.

Using custom graphics is not that difficult though, so have a go. There are plenty of free artifacts out there that you can use for the left and right side of the slider. They are referred to as minimum and maximum track image in the documentation.

What you need to remember when loading the image is to do something like this:

UISlider slider = ...;
UIImage* minImage = [UIImage imageNamed:@"my_min_image.png"];
UIImage* useableMinImage = [minImage stretchableImageWithLeftCapWidth:5 topCapHeight:4];
[slider setMinimumTrackImage:useableMinImage forState:UIControlStateNormal];

The stretchable image bit is the important thing to note. The leftCapWidth:5 is the non-stretchable part (width-wise) of the image - in the case of the default image it is the rounded part of the left side. The stretchable bit which is the blue bar is assumed to be 1 pixel wide, so in our case the 6th pixel. The rest of the image is assumed to be the right rounded bit (only drawn below the thumb if the slider is at the maximum value).

0

精彩评论

暂无评论...
验证码 换一张
取 消