使って創ってApp

ソフトウェアを使ったり作ったりするブログです

iOSアプリ開発でナビゲーションバーの色を変更する

iOSアプリ開発でナビゲーションバーの色を変更したかったので調べました。下記のサイトを参考にしました。

qiita.com

開発環境

ナビゲーションバーの色を変更する

AppDelegate の  application メソッドに下記のコードを入力します。

UINavigationBar.appearance().barTintColor = UIColor(red: 205/255, green: 55/255, blue: 55/255, alpha: 1.0)

f:id:hitxutokun:20151226215242p:plain

ナビゲーションバーのボタンとタイトルの色を変更する

AppDelegate の  application メソッドに下記のコードを追加します。

// タイトルの色を変更
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()]
// ボタンなどの色を変更 UINavigationBar.appearance().tintColor = UIColor.whiteColor()

 

f:id:hitxutokun:20151226220145p:plain