I have a problem understanding why, when I add a Map to my ScrollView, the element (in this case, Color.red) does not overlap with the navigation as shown in the picture. Does anyone know why this is happening and how to fix it? The problem occurs when the view has a navigationTitle and only happens with the Map.
import SwiftUI
import MapKit
struct ContentView: View {
var body: some View {
NavigationStack {
ScrollView(.vertical) {
Color.red
.padding(.top, -200)
.frame(height: 200)
Map().frame(minHeight: 300) // comment this line
}
.navigationTitle("Title")
.navigationBarTitleDisplayMode(.large)
}
}
}
#Preview {
ContentView()
}