使用此代码:
UISlider *slider = [[UISlider alloc]initWithFrame:sliderFrame];
[slider setThumbImage:[UIImage imageNamed:@"sliderThumb"] forState:UIControlStateNormal];
UIImage *sliderLeftTrackImage = [[UIImage imageNamed: @"sliderMin"] stretchableImageWithLeftCapWidth: 9 topCapHeight: 0];
UIImage *sliderRightTrackImage = [[UIImage imageNamed: @"sliderMax"] stretchableImageWithLeftCapWidth: 9 topCapHeight: 0];
[slider setMinimumTrackImage: sliderLeftTrackImage forState: UIControlStateNormal];
[slider setMaximumTrackImage: sliderRightTrackImage forState: UIControlStateNormal];
sliderMin 和 sliderMax 图像都是 210x34(与滑块框架大小相同)。sliderMin 为蓝色,sliderMax 为红色。当滑块一直向左时,我正确地看到了红色条。但是,在将拇指向右滑动几个像素后,整个条形图变为蓝色(sliderMin 图像)。显然我应该只看到滑块左侧的蓝色条。我究竟做错了什么?