滑块控件UISlider
滑块控件UISlider继承与UIControl
UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(30, 200, 300, 34)]; slider.minimumValue = 0; // 最小值 默认0 slider.maximumValue = 1; // 最大值 默认1 slider.thumbTintColor = [UIColor yellowColor]; // 设置滑块上thumb在不同状态下得图片slider // slider setThumbImage:<#(UIImage *)#> forState:(UIControlState) // 设置滑块已经划过区域的颜色 slider.minimumTrackTintColor = [UIColor greenColor]; // 设置滑块还未划过区域的颜色 slider.maximumTrackTintColor = [UIColor redColor]; // 设置最小值对应的图片 // slider.minimumValueImage // 设置最大值对应的图片 // slider.maximumValueImage slider.transform = CGAffineTransformMakeRotation(M_PI_2); [slider addTarget:self action:@selector(slid:) forControlEvents:(UIControlEventValueChanged)]; [self.view addSubview:slider]; [slider release];
- (void)slid:(UISlider *)slider { NSLog(@"%f", slider.value); self.view.backgroundColor = [UIColor colorWithRed:slider.value green:0 blue:0 alpha:1.0]; }