iOS 개발이야기

iOS13 다크모드 추후 대응을 위한 방법

Dustin. 2019. 10. 16. 15:31

iOS 13의 야심찬 기능 DarkMode.. 

 

Xcode 11로 빌드할 경우 기존에 사용하던 View의 BackgroundColor등이 다크모드에서 알아서 검게 변합니다.

 

다크모드일때의 디자인적인 측면에서 색상결정이 끝나지 않았다면 참 애매할텐데요.

 

친절하게 애플에서는 방법을 강구해 주었습니다.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        
        if #available(iOS 13.0, *) {
            self.window?.overrideUserInterfaceStyle = .light
        }
     
        return true
    }

 

요렇게 코드로 해주시거나

 

info.plist 파일에 

 

프로퍼티 UserInterFaceStyleLight로 설정하면 다크모드를 설정해도 임의로 색상이 변하지 않습니다.

 

 

https://developer.apple.com/documentation/uikit/uiview/3238086-overrideuserinterfacestyle