skip to Main Content

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Ω)   
}

2

Answers


  1. The goal is not clear but a possible variant is

    Text(String(describing: colorΩ))
    

    Tested with Xcode 14 / iOS 16

    demo

    Login or Signup to reply.
  2. You can also do it in another way similar to @Asperi answer:

    Text(colorΩ.description)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search