Launch Images for Dark or Light Mode
As the Launch Screen loads before the app starts executing, it would not be possible to change the launch images set programatically.
However, in the Image Set
tab, you can change the Appearance
option to enable a different set of images for Light and Dark modes:
So, if you set this image in the Launch Screen Storyboard, the result would be as below:
On a side note, if the need is just to change the background color, not the images, you may set the Launch Screen Storyboard view background color to System Background Color
and just use transparent .png images.
You need to add dark appearance for your asset, or for the asset color you are using, like in the image below:
You should do something like this to use light and dark mode images
Step 1 - Create image set in assets.xassets like this
Step 2 - Select Image select like this
- Steps 3 - Change appearance to Any, Light , Dark like this
- Add your images for any light and dark mode like this and use this image wherever you need it
- Xcode 11 supports only storyboard Launch screen files. It means I should use storyboards.
- In storyboards we can use UIImageViews + images from .xcassets. Assets support images with different variants: Light, Dark modes. You can apply constraints for positioning them on screen.
- If you support iOS before 11.0 you can not use system dynamic colors for backgrounds of the screen view. In this case you put additional dynamic image to screen as background and apply leading, trailing, top and bottom constraints with negative values. Negative values are needed for covering Top and Bottom Bars. (I used -64px)