How to get the name of a UIColor?

淺唱寂寞╮ 提交于 2019-12-11 10:25:49

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!