UISlider*slider = [[UISlideralloc]initWithFrame:CGRectMake(80,400,200,40)];
[self.view addSubview:slider];
[slider release];
slider.backgroundColor = [UIColor lightGrayColor];
//最小滑条颜色
slider.minimumTrackTintColor = [UIColor redColor];
//最大滑条颜色
slider.maximumTrackTintColor = [UIColor greenColor];
//设置滑块最小值
//设置滑块最大值
slider.maximumValue = 10;
//默认的值
slider.value = 5;
//核心方法
[slider addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
}
-(void)sliderAction:(UISlider *)slider
{
NSLog(@"value = %f",slider.value);
}
UISlider滑条
最新推荐文章于 2022-09-06 08:22:19 发布