简体   繁体   中英

UISLider setting thumb/minimumTrack/maximumTrack tint color gets exception

According to developer.apple I should be able to set UISLider's property - thumbTintColor/minimumTrackTintColor/maximumTrackTintColor - reference http://developer.apple.com/library/IOs/#documentation/UIKit/Reference/UISlider_Class/Reference/Reference.html

But setting any of these properties raises "unrecognized selector sent to instance" exception.

I know there is a workaround for this by setting image properties. But I don't want to go that way. Is there anything I'm missing?

Please any help is appreciated. Thanks in advance.

Here is the code from UICatalog project of developer.apple examples:

- (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;
}

You are trying to do this on not iOS5 devices/simulators. The API you want to use are only available on iOS5.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM