How to use dark mode in simulator iOS 13?
In Settings, scroll down to Developer and then Dark Appearance…
Update
In addition to the above, there are now many other ways to enable dark appearance in the simulator, as shown in the many great answers below.
• Change Environment Overrides from Xcode (@AshCameron)
• Toggle Appearance ⇧⌘A from the Simulator menu (@Shredder2794)
• Update from the command line using xcrun simctl ui booted appearance …
(@blackjacx, @tadija)
• Programmatically using overrideUserInterfaceStyle = .dark
(@thisIsTheFoxe)
• Specify UIUserInterfaceStyle
in your info.plist (@DhavalGevariya)
• Use SimGenie from Curtis Herbert… https://simgenie.app
How to enable Dark Mode on the Simulator?
There are two ways to activate the dark mode in Xcode 11. Both require you manual steps and are not automatic depending on the time.
1. Environment Overrides
The preferred one is to use the Environment Overrides inside Xcode. When running the App on the simulator in Xcode appears a button in the debugger controls next to 'Debug Memory Graph' and 'Simulate Location'. There you will find a menu for enabling dark mode, as well as choose text size and other accessibility settings.
2. Simulator Settings
Alternatively you can go inside the Settings App on the simulator:
Settings > Developer > Dark Appearance
How to use dark mode in simulator iOS 12.4?
Dark mode is available in iOS 13.0 and later
How to simulate dark mode on iOS Xcode Swift Playground
You can test it in any view using overrideUserInterfaceStyle
As an example, you can paste this code in a playground to check it (tested in Xcode 11.3.1):
import Foundation
import PlaygroundSupport
extension UIColor {
static var primary: UIColor {
UIColor { trait -> UIColor in
return trait.userInterfaceStyle == .light ? .black : .white
}
}
static var secondary: UIColor {
UIColor { trait -> UIColor in
return trait.userInterfaceStyle == .light ? .white : .black
}
}
}
class DarkModeTestView: UIView {
let label = UILabel(frame: CGRect(x: 0, y: 0, width: 375, height: 300))
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = .secondary
label.text = "This text should be displayed in black for light mode and white for dark mode"
label.textColor = .primary
label.numberOfLines = 0
addSubview(label)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
let testView = DarkModeTestView(frame: CGRect(x: 0, y: 0, width: 375, height: 300))
testView.overrideUserInterfaceStyle = .dark // Change here .light or .dark
PlaygroundPage.current.liveView = testView
Opting out of Dark Mode with iOS 15 using Xcode 13
For anyone else who lands here using Xcode 13. Here are the steps
- First, click on your project.
- Click on "Info"
- Click on the "+" on any Key to open a new K,V pair and add "Apperance" -> set value to "Light"
- Double check it exists in "Build Settings" under Info.plist Values under "User Interface Style" -> Light
Why doesn't my iOS app disable dark mode?
Simply you can add a new key UIUserInterfaceStyle
in your app info.plist (Notes: Xcode 12 and above has renamed to Appearance
) and set its value to Light or Dark
. this will override the app default style to the value you provide.
so you don't need to bother about having it anywhere else
Related Topics
Xcode Error While Validation - "Your Binary Is Not Optimized for iPhone 5"
Open Links in Safari Instead of Uiwebview
Add Cocoapods to Tests Target Too
How to Make Nsurlsession Post Request in Swift
The Sandbox Is Not in Sync with the Podfile.Lock-Ios
How to Position Views on Top of Each Other
Abpeoplepickernavigationcontroller Changes with iOS8
When Does Awakefromnib Get Called
Accessing Variables from Another Viewcontroller in Swift
Disable Wkwebview for Opening Links to Redirect to Apps Installed on My Iphone
Resize the Screen When Keyboard Appears
iOS Facebook Sdk - Post Open Graph and Show on Timeline Without Clicking Activity Log
Uicontroleventtouchdragexit Triggers When 100 Pixels Away from Uibutton
Timestamp Function That Has Been Working Reliably Just Caused Exc_Bad_Instruction