LoginSignup
1
1

More than 3 years have passed since last update.

NavigationBar,StatusBarの背景色と文字(アイコン)色の変更

Last updated at Posted at 2020-12-02

出来上がり

StatusBarとNavigationBarの背景をDarkGrayに、文字色を白にする

スクリーンショット 2020-12-02 23.38.07.png

1. Navigation Barのタイトル設定と背景色・文字色の変更

  override func viewDidLoad() {
    super.viewDidLoad()
    //NavigationBarのタイトルを設定
    navigationItem.title = "Title"

    //NavigationBarの背景色を設定
    navigationController?.navigationBar.barTintColor = .darkGray

    //NabigationBarのタイトルの文字色を設定
    navigationController?.navigationBar.titleTextAttributes = [.foregroundColor:UIColor.white]
  }

2. Status Barの文字色とアイコンの色変更

  • info.plistに「View controller-based status bar appearance」の項目を追加

  ※Valueは”NO”のまま

スクリーンショット 2020-12-02 22.49.43.png
※プラスを押して出たリストから選択(下の方)
 
 

  • Deployment Info(TARGETSのGeneral)の「Status Bar Style」を"Light Content"に変更

スクリーンショット 2020-12-02 21.57.57.png

以上でStatusBarの文字色が白になるはず

[環境]
Xcode 12.2

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1