title: Change UIView background color in SwiftUI
body: <p>Hello everyone. I'm creating a simple iOS app with SwiftUI, and I'd like to change my view's background color to a custom one I have.</p>
  
  <p>This is something extremely easy to do but it seems that it's impossible to achieve in SwiftUI without using ZStacks or workarounds like that, which if you use a List, for example, don't work.</p>
  
  <p>I want to <strong>change</strong> the color of the view, not use a ZStack with a custom color and then put the rest of the views on top of it. I tried using <code>UIView.appearance().backgroundColor = color</code> when initializing my view, but then all the view is hidden and the screen is filled with the color chosen.</p>
  
  <p>As I'm not good at explaining, here you have some images describing the problem:</p>
  
  <p><strong>Without color change</strong>
  <a href="https://i.stack.imgur.com/VCDcP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/VCDcP.png" alt="Without color change"></a></p>
  
  <p><strong>With color change</strong>
  <a href="https://i.stack.imgur.com/jyS46.png" rel="noreferrer"><img src="https://i.stack.imgur.com/jyS46.png" alt="With color change"></a></p>
  
  <h2>My code</h2>
  
  <pre><code>import SwiftUI
  
  struct TabController: View {
      @State private var selection = 0
  
      init() {
          UIView.appearance().backgroundColor = UIColor(named: "backgroundColor")
      }
  
      var body: some View {
          TabView(selection: $selection) {
              HomePageView()
                  .tabItem {
                      Image(systemName: "house.fill")
                          .font(.title)
                  }
                  .tag(0)
  
              Text("Second View")
                  .font(.title)
                  .tabItem {
                      Image(systemName: "bell.fill")
                          .font(.title)
                  }
                  .tag(1)
          }.edgesIgnoringSafeArea(.top)
      }
  }
  </code></pre>