SwiftUI NavigationBar not disappearing while scrolling

前端 未结 2 778
南笙
南笙 2021-01-15 15:17

I want to hide my NavigationBar while scrolling, actually It must hide automatically but when I tried with multiple views It doesn\'t work. Also, It works when

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-15 15:57

    Just idea, scratchy... try to put your custom views inside List as below (I know it will work, but I'm not sure if autohiding will work)

    NavigationView {
      List {
          SearchBar(searchText: $viewModel.searchText)
          StatusView(status: $viewModel.status)
          Divider()
    
          ForEach (0...viewModel.characters.results.count, id: \.self) { index in
          ...
    

提交回复
热议问题