'Simple SwiftUI Background Image keeps moving when keyboard appears

This is driving me nuts. There seems to be new behaviour for handling background images in iOS14.

Desired effect is: a fixed background image that fills the screen, ignoring the safe areas, and is totally static when the keyboard pops up. Instead the keyboard makes the image slide to the right, even though the keyboard is rising from the bottom (??).

Is this a SwiftUI bug? Any ideas/workarounds appreciated.

The code to produce this is very small:

import SwiftUI

struct ContentView: View {
    
    @State var name = "Name"
    
    var body: some View {
        GeometryReader { geometry in
            VStack {
                TextField("Placeholder", text: $name)
            }
            .frame(width: geometry.size.width, height: geometry.size.height)
            .background(
                Image("bricks")
                    .resizable()
                    .scaledToFill()
                    .edgesIgnoringSafeArea(.all)
            )
        }
    }
}


Solution 1:[1]

Ok, it turns our that adding the .frame call as follows allows the the background image to display as desired.

(Note specifically that the .frame call omits the height argument. In many previous tries to solve this the height was included, leading to the different undesired behaviour)

            .background(
                Image("bricks")
                    .resizable()
                    .scaledToFill()
                    .frame(width: geometry.size.width)
                    .edgesIgnoringSafeArea(.all)
            )

Solution 2:[2]

It's work for me:

.background(
                Image("bricks")
                    .resizable()
                    .scaledToFill()
                    .frame(width: geometry.size.width)
                    
            )
.edgesIgnoringSafeArea(.all)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ryan
Solution 2 quynhbkhn