草庐IT

colorWithRed

全部标签

ios - 有条件地分配 NSArray 而不会从静态分析器中获取错误?

对于以下代码NSArray*colors=[[NSArrayalloc]init];if([CONDITION]){colors=@[[UIColorcolorWithRed:240/255.fgreen:159/255.fblue:254/255.falpha:1],[UIColorcolorWithRed:255/255.fgreen:137/255.fblue:167/255.falpha:1],[UIColorcolorWithRed:126/255.fgreen:242/255.fblue:195/255.falpha:1],[UIColorcolorWithRed:119/

ios - UIColor colorWithRed :green:blue:alpha: always returns white unless one argument is 0 颜色

我正在使用[UIColorcolorWithRed:136green:155blue:218alpha:1.0];更改我的表格View单元格的背景颜色。但由于某种原因背景只是保持白色。如果我尝试[UIColorcolorWithRed:0green:155blue:218alpha:1.0];颜色变化。这对我来说没有意义。有什么建议或提示吗? 最佳答案 参数不是0到255之间的值,而是0.0到1.0之间的float:[UIColorcolorWithRed:0.0f/255.0fgreen:155.0f/255.0fblue:218