I usually use custom UIColors on iOS using extensions with Swift, but now with iOS 11/ Xcode 9 we can create Colors Sets. How can we use them?
Update - Tip>
In case you experience a delay with colors loading in a Swift Package when using UIColor(named:)
:
The answers above are totally valid for a regular project but if you are using assets in a swift package, you can see a delay when loading the colors when you use UIColor(named: "example_name")
. If you use UIColor(named: "background", in: Bundle.module, compatibleWith: .current)
overload that is targeting the module, the colors load immediately without any delay.
Note: I experienced with Xcode 12.1.