Friday, December 29, 2023
HomeiOS Developmentios - SwiftUI NavigationView Title Bar Taking Up Extreme Vertical House

ios – SwiftUI NavigationView Title Bar Taking Up Extreme Vertical House


I am creating an iOS app with SwiftUI and dealing with a difficulty the place the NavigationView title bar is taking over extra vertical area than I might like, and there is additionally extreme spacing above the primary card in a ScrollView. This occurs earlier than I begin scrolling and the area doesn’t cut back even after making use of .navigationBarTitleDisplayMode(.inline).

This is a simplified model of my view construction:

import SwiftUI
import FirebaseFirestore
import FirebaseAuth

struct DashboardView: View {
    @ObservedObject var tripManager: TripDataManager
    @ObservedObject var userViewModel: UserViewModel
    @State personal var username: String
    @State personal var showingAlert = false
    @State personal var alertMessage = ""
    
    public init() {
        self.tripManager = TripDataManager()
        self.userViewModel = UserViewModel()
        self.username = ""
    }
    
    var physique: some View {
        NavigationView {
            ScrollView {
                VStack(alignment: .main) {
                    // Playing cards...
                }
                .onAppear {
                    fetchUserData()
                }
            }
            .navigationTitle("Dashboard")
            .navigationBarTitleDisplayMode(.inline)
            .navigationBarItems(
                trailing: HStack {
                    Button(motion: { /* Person Profile Motion */ }) {
                        Picture(systemName: "individual.crop.circle")
                    }
                }
            )
        }
    }
    
    personal func fetchUserData() {
        // Fetch person information
    }
}

I’ve tried the next:

  • Making certain .navigationBarTitleDisplayMode(.inline) is ready.
  • Utilizing .edgesIgnoringSafeArea(.prime) to increase the ScrollView.
  • Making use of damaging padding to the highest of the ScrollView.
  • Cleansing the construct folder and restarting Xcode.

None of those have resolved the problem. The navigation bar nonetheless exhibits with a big vertical top, and there is a hole above the primary card inside the ScrollView.

Image of iOS Simulator showing the issue

Another Image of the iOS Simulator showing the issue



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments