xcode 如何在 UIProgressView 中设置进度色调颜色

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27815248/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 06:27:41  来源:igfitidea点击:

How to set the progress tint color in UIProgressView

iosxcodeuiprogressbar

提问by Javier Calatrava Llavería

I would like to know how to set UIProgressView tint color. Sometimes, depending on the color, the default height does not allow to see properly the progress. How to fix that issue?

我想知道如何设置 UIProgressView 色调颜色。有时,根据颜色,默认高度不允许正确查看进度。如何解决这个问题?

采纳答案by Javier Calatrava Llavería

This is for me the optimal way to do it:

这对我来说是最好的方法:

[progress setProgressTintColor:UIColorFromRGB(0xaa0000)];

where UIColorFromRGB is:

其中 UIColorFromRGB 是:

#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

(OPTIONAL): Sometimes, depending on the color, the progress is not properly appreciated and is necessary to increase the progress bar height:

(可选):有时,根据颜色的不同,无法正确理解进度,并且有必要增加进度条高度:

[progress setTransform:CGAffineTransformMakeScale(1.0, 3.0)];

回答by Rashad

You can set tint color of track and progress bar by this;

您可以通过此设置轨道和进度条的色调颜色;

For track color:

对于轨道颜色:

progress.trackTintColor = [UIColor whiteColor]; 

Progress bar:

进度条:

progress.progressTintColor = [UIColor redColor];

Hope this helps.. :)

希望这可以帮助.. :)

回答by Wim Deblauwe

In Swift, you can do it like this:

在 Swift 中,你可以这样做:

progressView.progressTintColor = UIColor.yellowColor()

回答by Zouhair Sassi

Swift 5:

斯威夫特 5:

progressBar.tintColor = UIColor(red: 33/255.0, green: 150/255.0, blue: 243/255.0, alpha: 1)
progressBar.tintColor = .blue