我正在创造(或试图)一种习俗,即UISlider,但仍然是横向的,但又是很大的taller。 我有两个问题。
1. 导言 这是用Im法把图像传给后代。
UIImage *minImage = [UIImage imageNamed:@"sliderMin.png"];
UIImage *maxImage = [UIImage imageNamed:@"sliderMax.png"];
UIImage *thumbImage = [UIImage imageNamed:@"sliderThumb.png"];
minImage = [minImage stretchableImageWithLeftCapWidth:33.0 topCapHeight:0.0];
maxImage = [maxImage stretchableImageWithLeftCapWidth:33.0 topCapHeight:0.0];
// thumbImage = [minImage stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0];
[_contrastSlider setMinimumTrackImage:minImage forState:UIControlStateNormal];
[_contrastSlider setMaximumTrackImage:maxImage forState:UIControlStateNormal];
[_contrastSlider setThumbImage:thumbImage forState:UIControlStateNormal];
minImage = nil;
maxImage = nil;
thumbImage = nil;
[_contrastSlider setMinimumValue:0.0];
[_contrastSlider setMaximumValue:100.00];
[_contrastSlider setValue:25.0];
我有三种图像,即min、max和.。 这些图像以及它们如何看待这些装置,这是正确的。
这里,我可以打上海报形象:MYSlider.jpeg<<><<>>>><<>>>>>>> 梯子应该对th子的权利,对左侧的ink子。 但是,情况并非如此。 That s problem 1. Problem 2 is the thumb size default is too small. I m using this :UISlider Height Hack to try to increase the height of the thumb, but sadly it s making it wider not taller. So I am asking for help to make the area taller, not wider, and wondering why my pink image is being ignored? 感谢你提供的任何帮助。 如果得到帮助,这里是我的UISlider子级: } 谢谢。-(BOOL) pointInside:(CGPoint)point withEvent:(UIEvent*)event {
CGRect bounds = self.bounds;
bounds = CGRectInset(bounds, -10, -8);
return CGRectContainsPoint(bounds, point);
-(BOOL) beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event {
CGRect bounds = self.bounds;
float thumbPercent = (self.value - self.minimumValue) / (self.maximumValue - self.minimumValue);
float thumbPos = THUMB_SIZE + (thumbPercent * (bounds.size.width - (2 * THUMB_SIZE)));
CGPoint touchPoint = [touch locationInView:self];
return (touchPoint.x >= (thumbPos - EFFECTIVE_THUMB_SIZE) && touchPoint.x <= (thumbPos + EFFECTIVE_THUMB_SIZE));
}