我正在定制我的UISlider:
[[UISlider appearance] setMinimumValueImage:[[UIImage imageNamed:@"slider_minimum.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 0)]];
[[UISlider appearance] setMaximumValueImage:[[UIImage imageNamed:@"slider_maximum.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 0)]];
这有点奏效,这是结果:
它有所作为,将图像放在任何一侧,但保留旧样式,并且不会拉伸我的图像。我究竟做错了什么? 感谢
答案 0 :(得分:5)
你可以这样做:
[slider setMinimumTrackImage:[[UIImage imageNamed:@"redSlider.png"] stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0] forState:UIControlStateNormal];
<强>结果:强>
答案 1 :(得分:0)
[slider setMaximumTrackImage:[[UIImage imageNamed:@"slider_maximum"]] forState:UIControlStateNormal];
[slider setMinimumTrackImage:[[UIImage imageNamed:@"slider_minimum"]] forState:UIControlStateNormal];