@property (nonatomic,strong)UISlider *VolSlider; _VolSlider=[[UISlider alloc]initWithFrame:CGRectMake(fDeviceWidth/4,fDeviceHeight*3/4-64,fDeviceWidth/2,30)]; _VolSlider.minimumValue=0.0; _VolSlider.maximumValue=30.0; _VolSlider.value=10;//设置默认值 //07.minimumTrackTintColor : 小于滑块当前值滑块条的颜色,默认为蓝色 _VolSlider.minimumTrackTintColor = [UIColor redColor]; // //08.maximumTrackTintColor: 大于滑块当前值滑块条的颜色,默认为白色 // slider.maximumTrackTintColor = [UIColor whiteColor]; // // //09.thumbTintColor : 当前滑块的颜色,默认为白色 // slider.thumbTintColor = [UIColor whiteColor]; [_VolSlider addTarget:self action:@selector(sliderValueChanged:) forControlEvents:UIControlEventValueChanged]; _VolSlider.continuous = NO;//当放开手., 值才确定下来 //把slider添加到视图上进行显示 [self.view addSubview:_VolSlider]; -(void)sliderValueChanged:(UISlider *)paramSender{ if ([paramSender isEqual:self.VolSlider]) { NSLog(@"New value=%0.2f",paramSender.value); } }