change height for navigation bar swift code example
Example 1: get height of navigation bar swift
let navigationBarHeight: CGFloat = self.navigationController!.navigationBar.frame.height
Example 2: swiftui change navigation bar height
//// ContentView.swift// test//// Created by Francisco Gindre on 1/3/20.// Copyright © 2020 Francisco Gindre. All rights reserved.//import SwiftUIstruct ContentView: View { init() { // this is not the same as manipulating the proxy directly let appearance = UINavigationBarAppearance() // this overrides everything you have set up earlier. appearance.configureWithTransparentBackground() // this only applies to big titles appearance.largeTitleTextAttributes = [ .font : UIFont.systemFont(ofSize: 20), NSAttributedString.Key.foregroundColor : UIColor.white ] // this only applies to small titles appearance.titleTextAttributes = [ .font : UIFont.systemFont(ofSize: 20), NSAttributedString.Key.foregroundColor : UIColor.white ] //In the following two lines you make sure that you apply the style for good UINavigationBar.appearance().scrollEdgeAppearance = appearance UINavigationBar.appearance().standardAppearance = appearance // This property is not present on the UINavigationBarAppearance // object for some reason and you have to leave it til the end UINavigationBar.appearance().tintColor = .white } var body: some View { NavigationView { ZStack { Color.black .edgesIgnoringSafeArea([.all]) NavigationLink(destination: ContentView2()) { Text("push") } } .navigationBarTitle("", displayMode: .inline) .navigationBarBackButtonHidden(true) } }}struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() }}struct ContentView2: View { var body: some View { ZStack { Color.black .edgesIgnoringSafeArea([.all]) NavigationLink(destination: ContentView()) { Text("push") } } .navigationBarTitle("My Custom White title", displayMode: .inline) }}