swiftuiscrollviewnavigationbarswiftui-navigationviewswiftui-scrollview

Scroll View Items Come Over the Navigation Bar in SwiftUI


I made a custom nav bar. and added a scroll view below it. The problem I am getting is when I scroll down, the data inside scroll view comes over the navigation bar. Here is the screenshot:

scroll view image

My code is:

struct NewsfeedView: View {
    
    var newsfeedModel: [NewsFeedData]
    
    var body: some View {
        
        VStack {
            
            CustomNavBar(navTitle: "Newsfeed")
            
            ScrollView {
                LazyVStack{
                    ForEach(newsfeedModel) { modelData in
                         
                        NewsFeedTableViewCell(newsFedd: modelData)
          }
        }
      }
    }.ignoresSafeArea()
  }
}

Does anyone knows what is the issue?


Solution

  • If it's undesired then just clip it, like

    ScrollView {
      // .. content here
    }
    .clipped()    // << here !!