#pragma mark 创建UISlider
UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(0,100,320, 100)];
// 划过的颜色设置
slider.minimumTrackTintColor = [UIColor redColor];
// 划前的颜色设置
slider.maximumTrackTintColor = [UIColor blueColor];
// 设置最小值
slider.minimumValue = 100;
// 设置最大值
slider.maximumValue = 200;
// 设置划过线的图片
[slider setMinimumTrackImage:[UIImage imageNamed:@"compass.png"] forState:UIControlStateNormal];
// 设置中间按钮的图片
[slider setThumbImage:[UIImage imageNamed:@"人物迷你版.png"] forState:UIControlStateNormal];
NSLog(@"%.1f",slider.value);
// 创建slider数值变时的触发事件
[slider addTarget:self action:@selector(slider:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:slider];
[slider release];
- (void)slider:(UISlider *)sender {
NSLog(@"%.1f",sender.value);
}