当前位置: 代码迷 >> 综合 >> UISlider 滑动条
  详细解决方案

UISlider 滑动条

热度:8   发布时间:2023-12-17 01:09:08.0
//滑块 音量设置,播放进度UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(0, 30, 300, 50)];//滑块左边的颜色slider.minimumTrackTintColor = [UIColor redColor];//滑块右边的颜色slider.maximumTrackTintColor = [UIColor greenColor];UIImage *thumb = [UIImage imageNamed:@"round_30"];//设置滑块的图片[slider setThumbImage:thumb forState:UIControlStateNormal];[slider setThumbImage:thumb forState:UIControlStateHighlighted];//gitHubs//google-code//source-forge//stackoverflow//设置最大值和最小值slider.maximumValue = 100;slider.minimumValue = 0;//设置默认值slider.value = slider.maximumValue /  2;[slider addTarget:self action:@selector(change:) forControlEvents:UIControlEventValueChanged];
- (void)change:(UISlider *)slider
{//获取当前进度float value = slider.value;NSLog(@"value = %f", value);
}