Home > Enterprise >  Use Color in Text() the right way
Use Color in Text() the right way

Time:07-31

How do I show my Color data in Text() view the right way? I tried 3 methods but not work for all.

Error = Initializer 'init(_:)' requires that 'Color' conform to 'StringProtocol'

var body: some View {
    Text("\(colorΩ)")
    Text(String(colorΩ))
    Text(colorΩ)   
}

CodePudding user response:

The goal is not clear but a possible variant is

Text(String(describing: colorΩ))

Tested with Xcode 14 / iOS 16

demo

CodePudding user response:

You can also do it in another way similar to @Asperi answer:

Text(colorΩ.description)
  • Related