SwiftUI Background Hidden

Hi, anyone know why my Background covered in black instead of the real Image? I think it hidden beneath those black color

Screenshot 2020-12-05 at 9.59.16 PM

What are you trying to accomplish? Also, please post the code and not an image of the code

Well, the rectangle uses a opaque foreground, you can fix that by setting it to .clear
However I do find it to be more intuitiv to use the Image as the central piece, and not the shape. See the two different approaches to accomplish the same result.

As you can see the ContentView2 uses the Image and add attributes to it, instead of using a Shape and adding content to it. Its much more clearer to read the code and understand it, if you always try to centralize the content and not the applied attributes.

import SwiftUI

struct ContentView: View {
    var body: some View {
        VStack {
            Rectangle()
                .frame(maxWidth: 316, maxHeight: 129, alignment: .leading)
                .foregroundColor(.clear)
                .background(
                    Image("xmas")
                        .resizable()
                        .scaledToFill()
                )
                .cornerRadius(8)
        }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

struct ContentView2: View {
    var body: some View {
        VStack {
            Image("xmas")
                .resizable()
                .scaledToFill()
                .frame(maxWidth: 316, maxHeight: 129, alignment: .leading)
                .clipShape(RoundedRectangle(cornerRadius: 20))
        }
    }
}

struct ContentView2_Previews: PreviewProvider {
    static var previews: some View {
        ContentView2()
    }
}

Thank you for your comprehensive reply, it was helpful! I think i will closed this issue since it was clearly resolved. :grinning: