根据developer.apple,我应该可以设置UISLider的属性 - thumbTintColor / minimumTrackTintColor / maximumTrackTintColor - reference http://developer.apple.com/library/IOs/#documentation/UIKit/Reference/UISlider_Class/Reference/Reference.html
但设置任何这些属性会引发“无法识别的选择器发送到实例”异常。
我知道通过设置图像属性可以解决此问题。但我不想那样走。有什么我想念的吗?
请任何帮助表示赞赏。提前谢谢。
以下是developer.apple示例的UICatalog项目代码:
- (UISlider *)sliderCtl
{
if (sliderCtl == nil)
{
CGRect frame = CGRectMake(174.0, 12.0, 120.0, kSliderHeight);
sliderCtl = [[UISlider alloc] initWithFrame:frame];
[sliderCtl addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
// in case the parent view draws with a custom color or gradient, use a transparent color
sliderCtl.backgroundColor = [UIColor clearColor];
// I just added this following line to test
sliderCtl.thumbTintColor = [UIColor yellowColor];
sliderCtl.minimumValue = 0.0;
sliderCtl.maximumValue = 100.0;
sliderCtl.continuous = YES;
sliderCtl.value = 50.0;
// Add an accessibility label that describes the slider.
[sliderCtl setAccessibilityLabel:NSLocalizedString(@"StandardSlider", @"")];
sliderCtl.tag = kViewTag; // tag this view for later so we can remove it from recycled table cells
}
return sliderCtl;
}
答案 0 :(得分:4)
您试图在非iOS5设备/模拟器上执行此操作。您要使用的API仅适用于iOS5。