美文网首页
UISlider实现滑动选择-ios

UISlider实现滑动选择-ios

作者: 桔子橙子柚子_F | 来源:发表于2018-09-07 17:52 被阅读0次

效果图:


效果图

创建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]; //选中的某个值
}

相关文章

网友评论

      本文标题:UISlider实现滑动选择-ios

      本文链接:https://www.haomeiwen.com/subject/rxzcgftx.html