Search code examples
swiftuicolors

Using custom color as background did not work


Custom color in asset folder so I could use with things like foregroundColor background and other.

I give this color name

 "CL1"

Example foregroundColor(Color("CL1")) background(Color("CL1"))

My problem right now I can't use this as background because i tried and its not working. Also no error alert.

Color("Cl1").ignoresSafeArea() //background

When apply with text it work.

Text("test").foregroundColor(Color("CL1"))

my proof


Solution

  • Try with ZStack

    ZStack {
      Color("CL1").ignoresSafeArea()
      Text("test")
    }