如何在进度更改时更改 UIProgressView 颜色 [英] How to change UIProgressView color while Progress Changes

查看:36
本文介绍了如何在进度更改时更改 UIProgressView 颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在进度更改时更改我的 UIProgressView 进度颜色.所以基本上它从白色开始,在接近尾声时变蓝.

I want to change my UIProgressView progress color while the progress changes. So basically it starts white and goes getting blue while it approaches the end.

这是我的代码:

-(void)changeSendProgProgress:(float)progress
{


    CGFloat redBlueValue = 255 - (255*progress);

    UIColor *colorProg = [UIColor colorWithRed:redBlueValue green:redBlueValue blue:255 alpha:1.0];

    [sendProgress setProgressTintColor:colorProg];
    [sendProgress setProgress:progress];


}

唯一的问题是进度颜色没有改变,一直到最后都保持白色.为什么它不改变?我应该使用像 dispatch_async(dispatch_get_main_queue() 这样的 UIThreading 吗?

the only problem is that the progress color doesn't change, it stays white all the way to the end. Why it doesn`t change? Should I use a UIThreading like dispatch_async(dispatch_get_main_queue() ?

推荐答案

在我看来,您实际上是在设置等于或小于 255 的整数值.关于 Apple 的文档,所有参数都应在 0.0 之间的 CGFloat 类型到 1.0.

It seems to me that you are actually setting integer values that are equal or smaller than 255. Regarding Apple's documentation, all the parameters should be in CGFloat type between 0.0 to 1.0.

请考虑这个链接.

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIColor_Class/index.html#//apple_ref/occ/clm/UIColor/colorWithRed:green:blue:阿尔法:

希望这会有所帮助.

这篇关于如何在进度更改时更改 UIProgressView 颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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