Dark mode launch screen in iOS 13
I've updated my iOS app to work in dark mode on iOS 13 but I am having trouble trying to get the launch screen to look good.
Currently it is a bright white screen with the app logo which looks awful in dark mode. I have tried setting the background colour of the launch screen to be a colour asset that I made with "Any Appearance" being white and "Dark Appearance" being black - but the launch screen still always shows as white.
Is there any way to get my launch screen to work properly in dark mode?
Solution 1:
When setting up the Launch Screen storyboard, set the view "Background" color to "System Background Color". This will be white in light mode and black in dark mode. No need to use your own color asset.
Solution 2:
I found a solution that supports earlier iOS versions as well as custom colors for each mode, dark and light, in iOS 13.
- Create an image asset, set Appearances to Any, Light, Dark, and load small solid pngs with your desired colors. In this case I am using orange for light, and black for dark.
-
Go to your LanuchScreen.storyboard and add an image view with that image asset. Place the image behind your image logo, set Content Mode as Aspect Fill, and constrain the view to the Superview in all sides. (Make sure that your logo looks good with the two backgrounds, or set its Appearance too)
-
This is where I had to do a trick. For some reason, I couldn't make the back image to show up. After checking some of the comments in Launch Screen storyboard not displaying image, I added the first image in the image asset to the target bundle
The color is static in older versions of iOS, and it works well with dark and light modes in iOS 13.
Solution 3:
I was updating my app to support new Dark Mode for iOS 13, I put "System Background Color" for the View's background in my LanuchScreen.storyboard, but surprisingly it didn't work!
The Logo image on the page was changing correctly based on Light/Dark Mode, but not the background!
I was about to apply Jose's solution, but before that, I decided to completely remove the app from my device and try again. And it worked!!
Solution 4:
I was missing colors from my color palette in Xcode defaulty offered colors so I created my own using Color.xcassets
where I created custom color set with appearences Any, Dark
and set my colors.
Then I can use them in autolayout same like System Colors even in LaunchScreen
Solution 5:
Yes Launch Screen work in dark mode, First check the background colour of your "xyz" image. if it is ok. just delete you app from device or simulator, because some time Launch Screen cached by device or simulator and you will not get the update UI on it. if you will face same problem just follow my demo app github.com/Indolia/darkmode.git