1 year ago

#360379

test-img

Adrien

ScrollView in a NavigationView with a .navigationTitle presented in a .sheet : animation glitch

The problem is very simple. I would like a ScrollView with a navigation bar (with its two appearances : a large title when the view is not scrolled ; a compact appearance otherwise). It's simple and it works...unless the view is presented with .sheet. At the "end of the scroll", the modal begins to lower. But if the user changes his mind... a problem with the transition between the "large" and "compact" states of the navigation bar appears.

Here is the result (iOS14/15, Simulator/Device) :

(Please click, the gif is animated)

enter image description here

And the code :

struct SwiftUIView: View {
  @State private var sheet: Bool = false
   
  var body: some View {
    Button("Tap") {
      sheet.toggle()
    }.sheet(isPresented: $sheet) {
      NavigationView {
        ScrollView {
          Text(String(repeating: "lol ", count: 1000))
        }
        .navigationTitle("Haha")
      }
    }
  }
}

Thanks for your help

swift

swiftui

uiscrollview

swiftui-navigationview

0 Answers

Your Answer

Accepted video resources