在所有视图控制器中隐藏状态栏 - IOS
Hide status bar in all view controllers - IOS
如果我想隐藏单个视图控制器子类的状态栏,那么我这样做:
override var prefersStatusBarHidden: Bool {
return true
}
但是如果我想在所有视图控制器子类中默认隐藏状态栏怎么办?在项目设置中检查 "Hide status bar" 没有任何作用。
我正在尝试对 UIPageViewController
进行编程,其中包含许多附加到它的视图控制器。最好不要将它们全部子类化。
转到您的 Info.plist 文件并添加一个新属性:
View Controller based status bar appearance
并将其设置为 NO
.
然后转到 App Delegate 并将您的方法替换为:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
UIApplication.shared.isStatusBarHidden = true
return true
}
右键单击您的 Info.plist
和 select Open As > Source code
在文件末尾,
之前
</dict>
</plist>
添加这个
<key>UIStatusBarHidden</key>
<true/>
或添加Status bar is initially hidden
并将其设置为YES
如果我想隐藏单个视图控制器子类的状态栏,那么我这样做:
override var prefersStatusBarHidden: Bool {
return true
}
但是如果我想在所有视图控制器子类中默认隐藏状态栏怎么办?在项目设置中检查 "Hide status bar" 没有任何作用。
我正在尝试对 UIPageViewController
进行编程,其中包含许多附加到它的视图控制器。最好不要将它们全部子类化。
转到您的 Info.plist 文件并添加一个新属性:
View Controller based status bar appearance
并将其设置为 NO
.
然后转到 App Delegate 并将您的方法替换为:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
UIApplication.shared.isStatusBarHidden = true
return true
}
右键单击您的 Info.plist
和 select Open As > Source code
在文件末尾,
之前</dict>
</plist>
添加这个
<key>UIStatusBarHidden</key>
<true/>
或添加Status bar is initially hidden
并将其设置为YES