UISlider thumbTintColor在iOS 7上没有变化(在iOS 6上很好) [英] UISlider thumbTintColor doesn't change on iOS 7 (fine on iOS 6)

查看:103
本文介绍了UISlider thumbTintColor在iOS 7上没有变化(在iOS 6上很好)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在iOS 6上完美运行的应用程序。我通过这种方式为UISlider的拇指设置了闪烁效果:

I have an app that runs perfectly on iOS 6. I've set a blinking effect to a UISlider's thumb this way:

-(void)startBlinkingSlider{
    isSliderBlinking = YES;
    isSliderTinted = NO;
    [self performSelector:@selector(toggleSliderColor) withObject:nil afterDelay:0.2];
}

-(void)toggleSliderColor{
    if(isSliderBlinking){
        if(isSliderTinted){
            self.effectAmountSlider.thumbTintColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:1];
        }else{
            self.effectAmountSlider.thumbTintColor = [UIColor colorWithRed:255 green:0 blue:0 alpha:1];
        }
        isSliderTinted = !isSliderTinted;
        [self performSelector:@selector(toggleSliderColor) withObject:nil afterDelay:0.2];
    }
}

-(void)stopBlinkingSlider{
    isSliderBlinking = NO;
    isSliderTinted = NO;
    self.effectAmountSlider.thumbTintColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:1];
}

当我打电话给 startBlinkingSlider 我的滑块在iOS 6中开始闪烁红色。如果我在iOS 7设备上运行相同的应用程序,则没有任何反应。滑块的拇指保留其原始的白色。我在设置 thumbTintColor 的行上设置了一个断点。在调试器中,这是我得到的:

When I call startBlinkingSlider my slider starts blinking red in iOS 6. If I run the same exact app on my iOS 7 device, nothing happens. The slider's thumb retains its original white color. I've set a breakpoint on the line where I set the thumbTintColor. In debugger, here is what I'm getting:

(lldb) po self.effectAmountSlider.thumbTintColor
error: failed to get API lock
(lldb) po self.effectAmountSlider.thumbTintColor
UIDeviceRGBColorSpace 0 0 0 1
(lldb) 

我键入了完全相同的代码,并在第一个中得到了一个奇怪的消息。但是,第二个结果是正确的。然后在将其设置为红色后,我也得到了正确的结果:

I typed the exact same code and got a weird message in the first one. However, the second result is correct. Then after setting it to red I'm also getting the correct result:

(lldb) po self.effectAmountSlider.thumbTintColor
UIDeviceRGBColorSpace 1 0 0 1

即使调试器显示正确的值,我也没有滑块的视觉变化。它仍然是白色,颜色不会以任何方式改变。我在这里搜索了Apple的文档: https://developer.apple.com/ library / ios / documentation / userexperience / conceptual / TransitionGuide / Controls.html

Even though the debugger shows the correct value, I'm getting no visual change in the slider. It's still white, color doesn't change in any way. I've searched Apple's documents here: https://developer.apple.com/library/ios/documentation/userexperience/conceptual/TransitionGuide/Controls.html

它没有说UISlider的thumbTintColor不能用作iOS 6。应该按预期保持工作。我检查了线程,一切都在主线程上运行。 toggleSliderColor 始终在主线程上,因此它不是线程问题。为什么我的拇指颜色不起作用?

It doesn't say anything about UISlider's thumbTintColor not working as iOS 6. It should stay working as expected. I've checked the thread and everything is running on the main thread. toggleSliderColor is always on the main thread so it's not a threading issue. Why is my thumb color not working?

谢谢,可以。

推荐答案

根据@ aaronsti的回答,我发现以下内容对我有用。将拇指图像设置为 nil 无效。

On basis of @aaronsti's answer I found that the following worked for me. Setting thumb-image to nil had no effect.

  [_slider setThumbImage:[_slider thumbImageForState:UIControlStateNormal] forState:UIControlStateNormal];
_slider.minimumTrackTintColor = minTintColor;
_slider.thumbTintColor = thumbTintColor;

这篇关于UISlider thumbTintColor在iOS 7上没有变化(在iOS 6上很好)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆