UISlider实现滑动选择-ios

2018-09-07  本文已影响0人  桔子橙子柚子_F

效果图:


效果图

创建UISlider

_slider.maximumValue = 4;
    _slider.minimumValue = 0;
    _slider.continuous = YES;
    [_slider addTarget:self
                action:@selector(valueChanged:)
      forControlEvents:UIControlEventValueChanged]; 
    [_slider setMinimumTrackImage:[UIImage imageNamed:@"jt"] forState:UIControlStateNormal];   
    [_slider setMaximumTrackImage:[UIImage imageNamed:@"ht"] forState:UIControlStateNormal];
    [_slider setThumbImage:[UIImage imageNamed:@"yd"] forState:UIControlStateNormal];
    [_slider setValue:1 animated:NO];
- (void)valueChanged:(UISlider *)sender {
    NSUInteger index = (NSUInteger)(_slider.value + 0.5);
    [_slider setValue:index animated:YES];
    NSString *select = _numArr[index]; //选中的某个值
}
上一篇 下一篇

猜你喜欢

热点阅读