• Feed
  • Explore
  • Ranking
/
/
    📱 iOS

    [iOS] 시스템 설정에 따라 다크모드 적용하기

    iosSwift
    지
    지성
    2025.02.17
    ·
    1 min read

    iOS에 시스템 설정에 따라 다크모드를 적용하려면,

    AppDelegate.swift의 didFinishLaunchingWithOptions 메서드에 아래 내용을 추가한다.

    @UIApplicationMain
    class AppDelegate: UIResponder, UIApplicationDelegate {
        var window: UIWindow?
    
        func application(_ application: UIApplication,
                         didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    
            if #available(iOS 13.0, *) {
                window?.overrideUserInterfaceStyle = .unspecified
            }
    
            return true
        }
    }

    왜 didFinishLaunchingWithOptions일까?

    앱 Launch 시점에 UI 전체 설정을 적용하기 때문이다.







    - 컬렉션 아티클