开发者

UISlider track image that doesn't stretch

I'm trying to use a custom track image for a UISlider but it is an asymmetric image from one end of the slider to the other.

I have tried sett开发者_开发问答ing up my image with leftCapWidth and so on but this just makes it take a maximum stretch and then starts spreading out one pixel of infor across the slider.

I'd like an image that doesn't change at all when you move the slider.

Is this at all possible?


You can use this to make the background of the UIslider custom ,make the UIslider as an IBoutlet

[yourslider setThumbImage:[UIImage imageNamed:@"icon0.png"] forState:UIControlStateNormal];



yourslider.minimumValue=1;
yourslider.maximumValue=10;

UIImage *sliderLeftTrackImage = [[UIImage imageNamed: @"yellow_bg.png"] stretchableImageWithLeftCapWidth: 9 topCapHeight: 0];
UIImage *sliderRightTrackImage = [[UIImage imageNamed: @"yellow_bg.png"] stretchableImageWithLeftCapWidth: 9 topCapHeight: 0];

[yourslider setMinimumTrackImage: sliderLeftTrackImage forState: UIControlStateNormal];
[yourslider setMaximumTrackImage: sliderRightTrackImage forState: UIControlStateNormal];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜