标签:
//初始化
UISlider *slider=[[UISlider alloc]initWithFrame:CGRectMake(0, 20, 200, 30)];
//最小值
slider.minimumValue=0;
//最小值位置图片
slider.minimumValueImage=[UIImage imageNamed:@"1.jpg"];
//最大值
slider.maximumValue=100;
//最大值图片
slider.maximumValueImage=[UIImage imageNamed:@"2.jpg"];
//默认值
slider.value=50;
//为YES时,其value就会随时变化,为NO时,则当滑动结束时,value才会改变
slider.continuous=YES;
//左边小数值颜色
slider.minimumTrackTintColor=[UIColor redColor];
//右边大数值颜色
slider.maximumTrackTintColor=[UIColor blueColor];
//滑块颜色
slider.thumbTintColor=[UIColor greenColor];
//手动设置数值
[slider setValue:5 animated:YES];
//左边小数值图片
[slider setMinimumTrackImage:[UIImage imageNamed:@"1.jpg"] forState:UIControlStateNormal];
//右边大数值图片
[slider setMaximumTrackImage:[UIImage imageNamed:@"2.jpg"] forState:UIControlStateNormal];
//添加事件,使用ValueChange
[slider addTarget:self action:@selector(change) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:slider];
标签:
原文地址:http://www.cnblogs.com/kyuubee/p/4804623.html