如何在UISlider上修复轨道填充图像?

时间:2014-08-22 04:51:18

标签: ios uislider

我有一个自定义UISlider图片用于我的轨道填充,但它超出了轨道的范围。

以下是 AppDelegate.m

中的代码
UIImage *minImage = [[UIImage imageNamed:@"slider-track-fill.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 4, 0, 4)];
UIImage *maxImage = [UIImage imageNamed:@"slider-track.png"];
UIImage *thumbImage = [UIImage imageNamed:@"slider-cap.png"];


[[UISlider appearance] setMaximumTrackImage:maxImage forState:UIControlStateNormal];
[[UISlider appearance] setMinimumTrackImage:minImage forState:UIControlStateNormal];
[[UISlider appearance] setThumbImage:thumbImage forState:UIControlStateNormal];
[[UISlider appearance] setThumbImage:thumbImage forState:UIControlStateHighlighted];

http://imgur.com/wI0RXGq - 这是我加载应用时的外观

1 个答案:

答案 0 :(得分:1)

您可能只想将剪辑设置为bounds = YES。

self.slider.clipsToBounds = YES;