title: how to change the text background color dynamically in swiftui?
body: <p>I want change the text background color with passing function to the   .background()like this, the value of color is 0 or 1 or 2 will depend on the data of DB .how can I fix it:</p>
  <pre><code>import SwiftUI
  
  struct ContentView: View {
      @State var color = 0;
      var body: some View {
          Text(&quot;Hello, World!&quot;)
              .background(changeBkColor(int : self.$color))
          
              
      }
  }
  func changeBkColor(int : color)
  {
      if(color == 1)
      {
          return Color.red;
      }
      else if(color == 2)
      {
          return Color.green;
      }
      else
      {
          return Color.blue;
      }
  }
  struct ContentView_Previews: PreviewProvider {
      static var previews: some View {
          ContentView()
      }
  }
  </code></pre>