UIKit - Navigation Title 색상 설정
SceneDelegate.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import UIKit
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(windowScene: windowScene)
let nav = UINavigationController(rootViewController: ViewController())
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = UIColor(named: "backgroundColor")
// Large Title 색상 설정
appearance.largeTitleTextAttributes = [.foregroundColor: UIColor.white]
// Title 색상 설정
appearance.titleTextAttributes = [.foregroundColor: UIColor.white]
UINavigationBar.appearance().scrollEdgeAppearance = appearance
UINavigationBar.appearance().standardAppearance = appearance
UINavigationBar.appearance().compactAppearance = appearance
window?.rootViewController = nav
window?.makeKeyAndVisible()
}
...
}
This post is licensed under CC BY 4.0 by the author.