All the articles only introduce the method of UIkit acquisition, and cannot be acquired using UIApplication.shared.statusBarFrame.height after iOS13.0
SwiftUI method for obtaining status bar and navigation bar
To get Navigation Bar you must embed your View In a NavigationView
eg :
eg :
Code Block struct ContentView: View { var body: some View { NavigationView { Text("Hello") .navigationBarTitle("Any title") } } }