How can we use Assets Catalog Color Sets?

后端 未结 9 1526
遇见更好的自我
遇见更好的自我 2020-11-29 06:57

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

9条回答
  •  自闭症患者
    2020-11-29 07:45

    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.

提交回复
热议问题