iOS App Development Study - How to apply UINavigationController in Code
iOS 어플 개발 공부 - 코드로 UINavigationController 적용하기
- 개발 환경 : MacBook Pro (13-inch, M1, 2020), Monterey
- XCode : Version 13.1 (13A1030d), Swift5
- 시뮬레이터 : iPhone 11
SceneDelegate 내 func scene() 코드 수정
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let windowScene = (scene as? UIWindowScene) else { return }
window?.windowScene = windowScene
window?.makeKeyAndVisible()
let controller = ViewController()
let navigationController = UINavigationController(rootViewController: controller)
window?.rootViewController = navigationController
}
ViewController 내 코드 작성
override func viewDidLoad() {
super.viewDidLoad()
// declare backgroundColor, default is black
view.backgroundColor = .white
...
// declare the top title
navigationItem.title = "Title"
// LargeTitle set is true
navigationController?.navigationBar.prefersLargeTitles = false
...
}
'iOS 앱 프로그래밍' 카테고리의 다른 글
[iOS Dev]UIFont.preferredFont(forTextStyle: UIFont.TextStyle) (0) | 2021.11.21 |
---|---|
[iOS Dev] Add UIButton, Alert programmatically (0) | 2021.11.18 |
[iOS Dev][AutoLayout] How to add UILabel with constraints - programmatically (0) | 2021.11.17 |
[iOS Dev] Hello World! (Storyboard, programmatically) (0) | 2021.11.16 |
[iOS Dev][Xcode] Assistant 기능 활용하기 (0) | 2021.11.12 |