How can I check whether dark mode is enabled in iOS/iPadOS?

前端 未结 16 1524
囚心锁ツ
囚心锁ツ 2020-12-08 09:41

Starting from iOS/iPadOS 13, a dark user interface style is available, similar to the dark mode introduced in macOS Mojave. How can I check whether the user has enabled the

16条回答
  •  北荒
    北荒 (楼主)
    2020-12-08 09:50

    in objective-c you'd want to do:

    if( self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ){
    
            //is dark
    }else{
    
        //is light
    
    }
    

提交回复
热议问题