More than 5 years have passed since last update.
NavigationBar,StatusBarの背景色と文字(アイコン)色の変更
1
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
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
