更改整個應用程式的狀態列樣式

迅速:

步驟 1:

Info.plist 中新增以下屬性:

View controller-based status bar appearance

並將其值設定為

NO

如下圖所示:

StackOverflow 文件

第 2 步:

在你的 AppDelegate.swift 檔案中,在 didFinishLaunchingWithOptions 方法中,新增以下程式碼:

UIApplication.shared.statusBarStyle = .lightContent

要麼

UIApplication.shared.statusBarStyle = .default
  • .lightContent 選項將顏色設定**狀態列。**為白色,整個應用程式。

  • .DEFAULT 選項將顏色設定**狀態列。**原來的黑色為主色調,整個應用程式。

Objective-C 的:

按照 SWIFT 部分的第一步。然後將此程式碼新增到 AppDelegate.m 檔案中:

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

要麼

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];