0

I am building an iPad app and occurred this weird laggy transition when I use a NavigationBar and a ScrollView. You can see it here (I don't know if there is another way to share videos).

My code looks like this:

NavigationView {
   ZStack {
      BackgroundView()
      GridView() 
   }
   .navigationTitle("HUB")         
   .toolbar{
      ...
   }
}
.navigationViewStyle(StackNavigationViewStyle())

BackgroundView:

var body: some View {
    ZStack {
        Image("background_light")
                .resizable()
                .ignoresSafeArea()
        
        VisualEffectView(effect: UIBlurEffect(style: .light))
            .ignoresSafeArea()
    }
}

GridView:

ScrollView {
    LazyVGrid(columns: homeViewModel.layout, spacing: 20, content: {
        ForEach(homeViewModel.itemButtons, id: \.self) { item in
            Button()
            ...
        }         
    }
}

Now I wonder whether it is a SwiftUI bug or I did something wrong and I hope you can help me.

Thank you and greetings from Germany.

EDIT: changed .navigationBarTitle() to .navigationTitle()

SirDeLight
  • 43
  • 1
  • 6
  • `navigationBarTitle` is being [deprecated](https://developer.apple.com/documentation/swiftui/view/navigationbartitle(_:)-6p1k7). You shouldn't use any of the `navigationBar` methods. use `.toolbar` and/or `.navigationTitle` – lorem ipsum May 11 '21 at 13:32
  • @loremipsum Thank you for the hint. I changed it to `.navigationTitle` and it was still laggy. I tried using the `.toolbar` but it didn't fix the lag. Any other ideas? – SirDeLight May 12 '21 at 06:58
  • Without a [Minimal Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) it is impossible to help you troubleshoot. – lorem ipsum May 12 '21 at 12:21
  • @loremipsum I added further explanation for the views I'm using. Do you need more to reproduce the troubleshoot? – SirDeLight May 14 '21 at 08:43

1 Answers1

0

Had a similar issue and my colleague suggested to add a padding on scroll view greater than 0. Adding 1pt padding fixed it for me. Looks like a SwiftUI bug which is not fixed for more than a year.