How to create Named colors in Interface Builder?

試著忘記壹切 提交于 2020-01-22 13:37:30

问题


How do I setup & use custom named colors in Interface Builder?


回答1:


In Xcode9 you can add "New Color Set" to .xcassets files, where you can set rgba values or use IB's color picker.

Then you can use that newly defined color from Interface Builder's color picker, it appears under the Named Colors section.

Or you can use it from code like UIColor(named:"customColorName").

As for now, Xcode9 beta 1 does not support using string literal color names as UIColor (like it works with UIImages), but I hope it will work in a later release.


Unfortunatelly it's only available for iOS11 and later.



来源:https://stackoverflow.com/questions/44625223/how-to-create-named-colors-in-interface-builder

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