How do I check weather Im in Dark Mode or not in UIKit

How in UIKit do i tell if the user is in dark mode or not

Answered by RyanTCB in 364125022

The viewcontroller has a traitCollection and you can query its userInterfaceStyle.

if  traitCollection.userInterfaceStyle == .light {
//light mode
}

You can check this property:

UITraitCollection.userInterfaceStyle


For a detailed explanation: https://schiavo.me/2019/implementing-dark-mode/

Accepted Answer

The viewcontroller has a traitCollection and you can query its userInterfaceStyle.

if  traitCollection.userInterfaceStyle == .light {
//light mode
}
How do I check weather Im in Dark Mode or not in UIKit
 
 
Q