UIColor colorWithRed:green:blue:alpha: always returns white unless one argument is 0

后端 未结 4 1145
轻奢々
轻奢々 2020-12-03 23:23

I am using

[UIColor colorWithRed:136 green:155 blue:218 alpha:1.0]; 

to change the background color of my table view cells.

But fo

4条回答
  •  时光说笑
    2020-12-03 23:51

    The values need to be floats (in the range 0.0 to 1.0), not ints (in the range 0 to 255).

    + (UIColor *)colorWithRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha
    

    Try:

    [UIColor colorWithRed:136.0/255.0 green:155.0/255.0 blue:218.0/255.0 alpha:1.0]; 
    

提交回复
热议问题