UISlider相关

时间:2023-03-09 03:52:22
UISlider相关
  • 设置slider当前位置的图像

        [slider setThumbImage:[UIImage imageNamed:@"dd.png"] forState:UIControlStateNormal];
  • 设置起始的颜色

    [slider setMinimumTrackTintColor:[ComHelper colorWithHex:SYSTEM_BLUE_COLOR]]
  • 设置末尾的颜色

    [slider setMaximumTrackTintColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:0.5]]
  • 设置为竖直的

    slider.transform = CGAffineTransformMakeRotation(-M_PI_2);
  • 重新设置slider的frame,并且设置为数值的
    一定要先设置transform为标准的,在设置frame,再设置transform

        slider.transform = CGAffineTransformIdentity;
    slider.frame = CGRectMake(0, 0, sliderLength, 20);
    [slider setCenter:CGPointMake(xCenter, yCenter)];
    slider.transform = CGAffineTransformMakeRotation(-M_PI_2);
  • 动态改变slider的值

    UIView.animateWithDuration(0.2, animations: {
    self.mySlider.setValue(0, animated:true)
    })

    the setValue animated parameter doesn't actually perform an animation, but rather it enables animation.

    To trigger the animation, you need to use UIView.animateWithDuration, and pass in the setValue command as the animation:

    Why isn't my UISlider animating