How to use dark mode in simulator iOS 13?

后端 未结 8 1809
迷失自我
迷失自我 2020-12-04 10:35

While I am developing the iOS app I need to test it in simulator with dark mode option so I can get more clarity about the app UI. But when I go to the Setting I am not gett

相关标签:
8条回答
  • 2020-12-04 10:57

    In Settings, scroll down to Developer and then Dark Appearance

    enter image description here


    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

    0 讨论(0)
  • 2020-12-04 10:59

    You can use the "Toggle Appearance" setting from the Simulator menu dropdown (Shift-Command-A):

    0 讨论(0)
  • 2020-12-04 11:01

    from terminal:

    xcrun simctl ui booted appearance light
    
    xcrun simctl ui booted appearance dark
    
    0 讨论(0)
  • 2020-12-04 11:03

    Automated Appearance Change

    0 讨论(0)
  • 2020-12-04 11:12

    There are two ways to enable dark mode in Simulator. Note: Make sure that you’re using iOS 13 simulator. X-D

    Solution 1: Change build settings

    1. Open Settings app
    2. Select Developer
    3. Enable Dark appearance

    Solution 2: Programmatically

    Simply add this code block in your ViewController file.

    override func viewDidLoad() {
        super.viewDidLoad()
        #if DEBUG
        // This changes appearance only for debug mode
        overrideUserInterfaceStyle = .dark
        #endif
    }
    

    Check this apple docs for more details.

    0 讨论(0)
  • 2020-12-04 11:15

    Alternatively, you can also switch the appearance programmatically (docs):

    override func viewDidLoad() {
        super.viewDidLoad()
        #if DEBUG
        // change the appearance only while testing  
        overrideUserInterfaceStyle = .dark
        #endif
    }
    
    0 讨论(0)
提交回复
热议问题