19

I have set up different backgrounds for 'Light/Dark Appearance'

enter image description here

But when switching between Light/Dark mode within Xcode, my background always uses image from 'Any/Light Appearance'. Only colours set for icons changes accordingly.

enter image description here

FYI: I'm switching between Light/Dark mode using Interface Style option.

enter image description here

Can someone please advice what I'm missing on? It's all new to me.

marika.daboja
  • 881
  • 13
  • 27
  • @matt I'm following online training which shows this functionality working correctly within Xcode by switching **Interface Style** on **Main.storyboard**. Just somehow I can't get same result. – marika.daboja Mar 27 '20 at 02:29
  • try running it on a device. Do u face the same issue on device with dark mode? – khush Apr 09 '20 at 06:43
  • @khush I don't have access to any devices apart from the build in Xcode simulator :( – marika.daboja Apr 14 '20 at 01:03
  • 6
    I am doing the same course and have the same problem. I also cloned the completed app and had the same problem. Changing "Render as" to "Original Image" made no difference for me. Fortunately I have an iPad I can download the app to and it works as expected - the correct image displays in light and dark modes. It must be a(nother) bug in Xcode. Keep doing the course - you didn't do anything wrong you'll just have to use your imagination for now. Sorry I can't comment on your question until I get 50 reputation but I hope this answer helps other students with the same problem. – RitchieLD Apr 23 '20 at 13:21
  • 1
    @RitchieLD thank you for your feedback. Good to know that I'm not the only one with this issue :) I'm still doing my course (I'm at 324 currently) and heads up there are more bugs in some of the chapters. – marika.daboja Apr 27 '20 at 00:59
  • [https://github.com/appbrewery/Clima-iOS13/issues/1](https://github.com/appbrewery/Clima-iOS13/issues/1) – Gilgamesh Skytrooper May 13 '20 at 02:22

9 Answers9

19

I think it is an Xcode bug. You can confirm it by changing your setting in the iOS Simulator.

Go to Settings -> Developer -> Dark Appearance

shim
  • 9,289
  • 12
  • 69
  • 108
Ikhsannul Hijri
  • 266
  • 2
  • 12
  • This worked! Switching Appearance on the emulator had an effect on the app background as expected (different background image for different appearance). So happy to classify it as an another ;) Xcode bug. Thanks! – marika.daboja May 26 '20 at 13:15
  • Where do you find the settings menu? I only have "preferences" available in Xcode – Marcus Kim Jul 14 '20 at 00:24
  • Nvm. Got it. When you said emulator, it threw me off. I should've known you meant simulator since emulator and simulator mean the same thing in this case. For all those reading this comment, go to Setting within the iPhone Simulator – Marcus Kim Jul 14 '20 at 00:31
  • 1
    In Xcode 12 Simulator, go to Features -> Toggle Appearance (shift + command + A). – P. Stern Jan 05 '21 at 05:58
11

I think you might need to uncheck the Resizing checkbox and set the Scales property to Single Scale. It worked for me.

enter image description here

2rahulsk
  • 488
  • 4
  • 10
  • Hmm...How do I get to that menu? My background object doesn't have Image Set tab.. – marika.daboja May 26 '20 at 13:16
  • 1
    Go to Assests.xcassets folder and click on the image you have. Then in the right pane you can uncheck the Preserve Vector Data checkbox. This will help you with your concern. Also, remember to check this checkbox when you build and run the code in so that you won't get any pixelation. – 2rahulsk Jun 02 '20 at 09:48
  • Thanks! I haver just tested and in fact that fixed my problem. I still don't understand why it wasn't working before with this option on. So you are saying to keep it unticked just for testing purposes while I'm developing but before actual build to untick? Sounds like Xcode bug after all - since I would expect Xcode to mimic actual phone device behaviour. Thank you for your help anyway! – marika.daboja Jun 02 '20 at 11:19
0

Set your image to Render As Original Image

erictruong
  • 303
  • 3
  • 14
0

I think it's an Xcode (latest version) bug.

If you run it on your phone, you won't have this problem. Meaning settings are correct.

Ardent Coder
  • 3,777
  • 9
  • 27
  • 53
XYD
  • 591
  • 1
  • 5
  • 9
0

In Simulator it's working fine. One can confirm by toggling the Appearance from feature menu of the simulator.

0

This seems like an Xcode bug, but when you try to run it on your simulator or physical device, it should work perfectly assuming you are in Dark Mode.

Rhenz
  • 2,293
  • 1
  • 14
  • 14
0

By unchecking the Preserve Vector Data option 1, one can see the change in the background when switching between the modes from interface styles 2.

But I noticed that if you leave the option selected and test it on the simulator, it works perfectly fine there. Hence I feel it's an Xcode bug too.

enter image description here

enter image description here

Sahil Tah
  • 300
  • 1
  • 3
  • 9
0

The Xcode Bug is still here, Xcode storyboard appearance switcher does not work, it only works in the simulator.
You can change the simulator device appearance: Settings> Developer> Dark Appearance.


Happy coding.

Debashish M
  • 193
  • 3
  • 13
0

On my physical device iPhone 8 iOS 14.6 dark Mode doesn't work. traitCollectionDidChange not get called after switching to dark mode. On my iPhone 12 iOS 15.x, and some testers it works. No Solution i tried worked. Also i got some other weird UI bugs aswell on my iPhone 8.

Hope its just an Xcode Bug.

Mobias
  • 31
  • 3