Search code examples
iosxcodeuiprogressbar

How to set the progress tint color in UIProgressView


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?


Solution

  • This is for me the optimal way to do it:

    [progress setProgressTintColor:UIColorFromRGB(0xaa0000)];

    where UIColorFromRGB is:

    #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)];