title: SwiftUI - How to prevent keyboard in a sheet to push up my main UI
body: <p>I'm using sheets (SwiftUI) during an onboarding to let people enter text, however whenever the sheet is dismissed, the elements in the background move, as if the keyboard was pushing them up and down. If the keyboard is not on screen, the elements in the background don't move when the sheet is dismissed. I've tried to use .ignoresSafeArea(.keyboard, edges: .bottom) but it doesn't seem to work.</p>
  <p>Any idea regarding how to &quot;fix&quot; the background elements while a sheet with a keyboard is dismissed?</p>
  <p><a href="https://i.stack.imgur.com/BpIco.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BpIco.gif" alt="" /></a></p>
  <pre><code>  private var welcomeSection5: some View {
      ZStack {
          VStack {
              
              // This is the part that moves up and down
              TellSlideView(text: &quot;And what's your age \(userName) if I may?&quot;)
              Spacer()
              Button(action: {
                  displaySheet.toggle()
  
              }, label: {
                  Text(&quot;Enter age&quot;)
                      .padding()
                      .foregroundColor(Color.white)
                      .frame(maxWidth: .infinity)
                      .background(Color.MyTheme.Purple)
                      .cornerRadius(15)
                      .padding(.horizontal)
                      .padding(.bottom, 40)
              })
          }.sheet(isPresented: $displaySheet) {
              AddUserAgeView(onboardingState: $onboardingState)
          }.ignoresSafeArea(.keyboard, edges: .bottom)
      }
  }
  </code></pre>