UITabBarControllerのボタンの色を変える


はじめに

UITabBarControllerのボタンの色を変えたい。

環境

Xcode 12.4
Swift 5.3.2

実装

タブバーコントローラーに遷移する前の画面で色を指定しました。

MenuViewController
override func viewDidLoad() {
    UITabBar.appearance().tintColor = .red
    UITabBar.appearance().unselectedItemTintColor = .darkGray
}

func next() {
    let storyboard = UIStoryboard(name: "Next", bundle: nil)
    let next = storyboard.instantiateViewController(identifier: "Next")
    guard let tabBarCon = next as? UITabBarController else { return }
    self.navigationController?.pushViewController(tabBarCon, animated: true)
}

結果

感想

今後も何度か調べそうな内容だなと思いました。
参考記事に感謝です。

参考記事