问题
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