html的slider位置调整,ios设置UISlider的起始位置和增量

越伯寅
2023-12-01

有谁知道如何设置UISlider的起始位置(理想情况是在中间)以及如何将其增加到数十而不是一些?

这是我到目前为止所得到的:

// Setup custom slider images

UIImage *minImage = [UIImage imageNamed:@"ins_blueTrack.png"];

UIImage *maxImage = [UIImage imageNamed:@"ins_whiteTrack.png"];

UIImage *tumbImage= [UIImage imageNamed:@"slide.png"];

minImage=[minImage stretchableImageWithLeftCapWidth:6.0 topCapHeight:0.0];

maxImage=[maxImage stretchableImageWithLeftCapWidth:6.0 topCapHeight:0.0];

// Setup the slider

[self.slider setMinimumTrackImage:minImage forState:UIControlStateNormal];

[self.slider setMaximumTrackImage:maxImage forState:UIControlStateNormal];

[self.slider setThumbImage:tumbImage forState:UIControlStateNormal];

self.slider.minimumValue = 10;

self.slider.maximumValue = 180;

self.slider.continuous = YES;

int myVal = self.slider.value;

NSString *timeValue = [[NSString alloc] initWithFormat:@"%1d", myVal];

self.timeLabel.text = timeValue;

// Attach an action to sliding

[self.slider addTarget:self action:@selector(fxSliderAction) forControlEvents:UIControlEventValueChanged];

 类似资料: