Dans SwiftUI, l'arrière-plan n'était pas rempli comme prévu, j'ai donc essayé de savoir où et comment il serait rempli.
struct ContentView: View {
        
    var body: some View {
        VStack {
            Spacer()
            Text("Hello world!")
                .foregroundColor(Color.white)
                .background(Color.green)
                .frame(maxWidth: .infinity, minHeight: 50)
                .background(Color.blue)
                .padding()
                .background(Color.orange)
            Spacer()
        }.frame(width: 320, height: 100)
    }
    
}
// Present the view controller in the Live View window
PlaygroundPage.current.liveView = UIHostingController(rootView: ContentView())

--Si vous spécifiez background avant frame, il sera rempli dans la limite de texte (vert).
--S'il y a un "arrière-plan" après le "cadre" et un "remplissage" après le "fond", il est rempli à l'intérieur par le "remplissage" (bleu).
--Si vous spécifiez background après padding, la zone où padding est également ignoré est remplie (orange).
En prêtant attention à la position de background de cette manière, il semble que vous puissiez remplir comme prévu.
Recommended Posts