我正在尝试将 UIButton 的背景颜色更改为自定义颜色。所有默认的灰色、蓝色等都不够用。
UIColor *myColor=[UIColor colorWithRed:1 green:1 blue:0 alpha:1.0f];
_button.backgroundColor = [UIColor myColor];
第二行出错
No known class method for selector 'myColor'
最佳答案
你的代码很好,简单的错误是你又在第二行创建了[UIColor property]
UIColor *myColor=[UIColor colorWithRed:1 green:1 blue:0 alpha:1.0f];
不像
_button.backgroundColor = [UIColor myColor];
喜欢
_button.backgroundColor = myColor;
更新
you can directly use the color property like
_button.backgroundColor = [UIColor colorWithRed:1 green:1 blue:0 alpha:1.0f];
关于ios - 自定义设置按钮背景色ios,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35740189/