UI UISlider滑块控件

<span style="font-size:18px;">    //创建slider对象
    UISlider *slider=[[UISlider alloc]initWithFrame:CGRectMake(20, 200, 280, 50)];
    //定义划过区域的颜⾊
    slider.minimumTrackTintColor=[UIColor redColor];
    //定义未划过区域的颜⾊
    slider.maximumTrackTintColor=[UIColor blackColor];
    //定义圆圈的图片
    [slider setThumbImage:[UIImage imageNamed:@"2.jpg"] forState:UIControlStateHighlighted];
    //定义圆圈的颜色,不管用(先设置图片再设置颜色就管事了)
    slider.thumbTintColor=[UIColor blueColor];

    //设置slider的最大最小值
    slider.minimumValue=100;
    slider.maximumValue=200;
    //滑块的旋转
    slider.transform=CGAffineTransformMakeRotation(M_PI/2);
    //添加事件
    [slider addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:slider];
    [slider release];</span>

你可能感兴趣的:(UI UISlider滑块控件)