I want to use my color assets from the assets catalog using color literals.
In UIKit
, we can directly use color literal is there any way to use color literals in SwiftUI
I have searched from Color initializer with UIColor
parameter but none found
Note: From Xcode 11 Beta 5, Color
has an initializer for this already and no need to implement it.
So you can use colorLiteral like this:
Color(#colorLiteral(red: 1, green: 0, blue: 0, alpha: 1))
Or any other CGColor
, UIColor
(or NSColor
for macOS):
Color(.red)