地址:https://github.com/ShuailongWang/slider
使用:
把文件拖进去后,导入头文件
注意:这个是使用 UITapGestureRecognizer 会和侧滑返回冲突,
解决: 禁用侧滑返回
代码:
if (nil == _slider) {
_slider = [[SEFilterControl alloc]initWithFrame:CGRectMake(10, 5, KScreen_Width - 20, 15) Titles:[NSArray arrayWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9", nil]];
[_slider addTarget:self action:@selector(filterValueChanged:) forControlEvents:UIControlEventTouchUpInside];
[_slider setProgressColor:[UIColor grayColor]];//设置滑杆的颜色
[_slider setTopTitlesColor:[UIColor redColor]];//设置滑块上方字体颜色
[_slider setSelectedIndex:0];//设置当前选中
_slider.backgroundColor = [UIColor whiteColor];
[self.SliderView addSubview:_slider];
}
代理:
-(void)filterValueChanged:(SEFilterControl *)sender {
NSLog(@"%d", sender.SelectedIndex);
}