我有一个自定义滑块,当我来回滑动时,轨道图像似乎左右移动了一点。有人知道为什么会这样吗?
UIImage *stetchLeftTrack = [[UIImage imageNamed:highBar] stretchableImageWithLeftCapWidth:capLeft topCapHeight:0.0];
UIImage *stetchRightTrack = [[UIImage imageNamed:grooveBar] stretchableImageWithLeftCapWidth:capRight topCapHeight:0.0];
[customSlider setThumbImage: [UIImage imageNamed:thb] forState:UIControlStateNormal];
[customSlider setThumbImage: [UIImage imageNamed:thbH] forState:UIControlStateHighlighted];
[customSlider setMinimumTrackImage:stetchLeftTrack forState:UIControlStateNormal];
[customSlider setMaximumTrackImage:stetchRightTrack forState:UIControlStateNormal];
答案 0 :(得分:1)
你的capLeft和capRight值是否可能不符合预期(它们应该是非零整数)?它可能会拉伸整个图像,而不仅仅是您想要伸展的部分。