UISlider 滑动条

//滑动条
    UISlider* slider = [[UISlider alloc] initWithFrame:CGRectMake(50, 50, 220, 0)];
    //最小值
    [slider setMinimumValue:0.0];
    //最大值
    [slider setMaximumValue:10.0];
    //当前值
    [slider setValue:2.0 animated:YES];
    //最小值图片
    [slider setMinimumValueImage:[UIImage imageNamed:@"main_left_nav.png"]];
    //最大值图片
    [slider setMaximumValueImage:[UIImage imageNamed:@"main_right_nav.png"]];
    // 最小值轨道图片
    //[slider setMinimumTrackImage:[UIImage imageNamed:@"main_left_nav.png"] forState:UIControlStateNormal];
    //最大值轨道图片
    //[slider setMaximumTrackImage:[UIImage imageNamed:@"main_right_nav.png"] forState:UIControlStateNormal];
    //最小值轨道颜色
    [slider setMinimumTrackTintColor:[UIColor redColor]];
    //最大值轨道颜色
    [slider setMaximumTrackTintColor:[UIColor yellowColor]];
    //设置滑块颜色
    [slider setThumbTintColor:[UIColor clearColor]];
    //设置滑块图片
    [slider setThumbImage:[UIImage imageNamed:@"main_left_nav.png"] forState:UIControlStateNormal];
    [slider setThumbImage:[UIImage imageNamed:@"main_left_nav.png"] forState:UIControlStateHighlighted];
    //事件
    [slider addTarget:self action:@selector(slider:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:slider];
    //[slider release];
    
    
    
    ///获取 值
    - (void)slider:(UISlider*)slider{
    NSLog(@"%f",slider.value);
}


你可能感兴趣的:(UISlider,滑动条)