How to set Root view Controller & Statusbar Height in SwiftUI
SwiftUI RootView & StatusBar| Set the root view controller and adjust status bar height in SwiftUI apps. Follow the step-by-step guide on rrtutors.com.
In this SwiftUI example we will learn how to set rootview controller. After Creating Your SwiftUI Project. Follow below steps to create dashboard screen
Open your project Go to File —> New —> File… Here You can select a SwiftUI View in User Interface and Click on Next —> Give a name for your file (Here i given Home as File name) and Click on Create
![]() |
Go to SceneDelegate change rootView as Home under willConnectTo session Delegate. Because here i want to show Home View as soon as App launch.
![]() |
Below code will set the height of Statusbar in swiftUI
let window = UIApplication.shared.windows.filter {$0.isKeyWindow}.first let statusBarHeight = window?.windowScene?.statusBarManager?.statusBarFrame.height ?? 0 let screen = UIScreen.main.bounds |