如何找到UIButton的当前背景颜色

时间:2014-08-13 14:57:22

标签: ios objective-c xcode uibutton uicolor

如何找到UIButton的当前背景颜色并将该颜色名称存储在NSString或NSMutableArray中。

2 个答案:

答案 0 :(得分:0)

在这里,你去找我的朋友。

UIColor* buttonColor = button.backgroundColor;
NSString* colorString = [buttonColor description];

答案 1 :(得分:0)

uicolors没有名字

但是你可以使用erica sudan的类别

How to get the name of a UIColor?

找到颜色最接近的颜色名称

(免责声明:不是我的代码)

或者使用十六进制值:

请参阅https://github.com/timd/UIColor-HexValues

它在UIColor上有一个类别,从颜色到十六进制以及从十六进制到颜色

(免责声明:不是我的代码)