//滑块 设置高度
UISlider * slider = [[UISlider alloc] initWithFrame:CGRectMake(20, 100, CGRectGetWidth(self.view.frame) - 40,30 )];
// slider.backgroundColor = [UIColor grayColor];
slider.minimumValue = 10;
slider.maximumValue = 50;
//较小值轨道颜色
slider.minimumTrackTintColor = [UIColor greenColor];
//较大值轨道颜色
slider.maximumTrackTintColor = [UIColor redColor];
//拖动圆圈的颜色
slider.thumbTintColor = [UIColor yellowColor];
slider.value = 30;
//能否连续调用valuechange
slider.continuous = NO;
//最小端添加图片
slider.minimumValueImage = [UIImage imageNamed:@"apply_sex_normal"];
//最大端添加图片
slider.maximumValueImage = [UIImage imageNamed:@"apply_sex_selected"];
//滑块的图片
[slider setThumbImage:[UIImage imageNamed:@"apply_sex_selected"] forState:UIControlStateNormal];
//较小端轨道的图片
[slider setMinimumTrackImage:[UIImage imageNamed:@"apply_sex_normal"] forState:UIControlStateNormal];
[slider addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:slider];
}
- (void)sliderAction:(UISlider *)slider {
self.switchLabel.font = [UIFont systemFontOfSize:slider.value];
}