ios – Removing initial space from ScrollView in swift UI

0
69


I’m having trouble with the initial position of a Scroll View in my iOS app:there’s a toolbar and my scroll view is wrapped inside the NavigationView.I would like to remove the spacing between “Testo 1” and the top navigation bar.I’ve searched on the internet but I’ve only found something about ScrollViewReader,but actually I need to remove the space when the view loads. Is it possible to remove that space?
In the first image you’ll see what happen when I open the app, then what appears when I scroll down

enter image description here

enter image description here

That’s my code:

import SwiftUI
struct ProvaScrollView: View {
    var body: some View {
        NavigationView(){
            
            ScrollView{
                Text("Testo 1")
                VStack{
                    CardView(title: "Title", text: "Card Text", colore:.blue)
                    Spacer(minLength: 10)
                    Title(testo: "Titolo 2")
                    Spacer(minLength: 3)
                    Text("Descrizione ")
                        .multilineTextAlignment(.center)
                    dishImage()
                    
                }}
            .padding().toolbar(){
                ToolbarItem(placement:.navigation){
                    NavigationLink(destination: ListOfRecipes()){
                        Text("Back")
                    }
                }
                ToolbarItem(placement:.principal){
                    Text("Prova Scroll View")
                        .font(.system(size: 20))
                        .fontWeight(.black)
                }
                
            }
            .ignoresSafeArea(.all, edges: .bottom)
        }.navigationBarBackButtonHidden()
    }
    
}

Thanks in advance