开发者

UISlider's track images don't stretch right on iOS 3.2+

开发者 https://www.devze.com 2023-01-13 07:23 出处:网络
I have a UISlider subclass that is supposed to implement a custom look. I\'m doing this with stretchable images:

I have a UISlider subclass that is supposed to implement a custom look. I'm doing this with stretchable images:

UIImage*    sliderBar = [UIImage imageNamed: @"SliderLeft.png"];
UIImage*    sliderLeft = [sliderBar stretchableImageWithLeftCapWidth: 7 topCapHeight: 0];
sliderBar = [UIImage imageNamed: @"SliderRight.png"];
UIImage*    sliderRight = [sliderBar stretchableImageWithLeftCapWidth: 1 topCapHeight: 0];
UIImage*    sliderRing = [UIImage imageNamed: @"SliderRing.png"];
UIImage*    sliderRingH = [UIImage imageNamed: @"SliderRing-Highlighted.png"];

[self setMinimumTrackImage: sliderLeft forState: UIControlStateNormal];
[self setMaximumTrackImage: sliderRight forState: UIControlStateNormal];
[self setThumbImage: sliderRing forState: UIControlStateNormal];
[self setThumbImage: sliderRingH forState: UICont开发者_开发百科rolStateHighlighted];

This works fine on a device running 3.1.3. However, on an iPad (3.2.x) or iOS 4.x device, it looks like it's stretching the rightmost pixels, and never drawing the endcap.

SliderLeft.png is 8 pixels wide (there is no right endcap), SliderRight.png is 11 px.

I'm not seeing that anything here changed in UIImage or UISlider.

Are there any known gotchas here? Like I said, it was all working when I wrote it, but newer OSes seem to break it.

0

精彩评论

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

关注公众号