How can dark mode be detected on macOS 10.14?

前端 未结 6 1328
天涯浪人
天涯浪人 2020-12-13 20:51

In macOS 10.14 users can choose to adopt a system-wide light or dark appearance and I need to adjust some colours manually depend of the current mode.

6条回答
  •  爱一瞬间的悲伤
    2020-12-13 21:30

    To know if the app appearance is Dark, use next code:

    + (BOOL)isDarkMode {
        NSString *interfaceStyle = [NSUserDefaults.standardUserDefaults valueForKey:@"AppleInterfaceStyle"];
        return [interfaceStyle isEqualToString:@"Dark"];
    }
    

提交回复
热议问题