UIColor 在设置蓝色时始终显示白色



我正在尝试用这个设置UIImageView的背景颜色(它应该返回一些绿色的颜色):

 cell.background.backgroundColor = [UIColor colorWithRed:50 green:200 blue:50 alpha:1];

但是由于某种原因,这只是给了我白色,似乎每当我设置蓝色时,它就会变回白色,当我这样做时,它会让我返回黄色,这是正常的:

cell.background.backgroundColor = [UIColor colorWithRed:50 green:200 blue:0 alpha:1];

好的,我没有意识到 UIColor 需要从 0 - 1 的浮点数,而不是从 0 - 255 的浮点数,这有效:

cell.background.backgroundColor = [UIColor colorWithRed:240.0f/255.0f green:245.0f/255.0f blue:254.0f/255.0f alpha:1];

最新更新