问题
I have an array of UIColors like
[UIColor blueColor];
is it possible to get the name "blue" from that UIColor, to display it in a string?
回答1:
There's nothing built in to UIKit, but Erica Sadun's uicolor-utilities library adds similar functionality.
回答2:
You can get RGB and Alpha of the UIColor, if you want.
回答3:
A list of color names can be obtained using runtime.
See my question: How to get all Color methods of UIColor?
You can also use string methods to convert 'xxxColor' to 'xxx' if needed.
来源:https://stackoverflow.com/questions/15582801/how-to-get-the-name-of-a-uicolor