I am developing a Mac Cocoa app. And I have a set of images to adopt for both light and dark modes.
I followed the instructions here: https://developer.apple.com/documentation/uikit/uiimage/providing_images_for_different_appearances
In viewWillLayout()
, I set up an image for a view like so:
nsImgaeView.image = NSImage(named: "Image") // Does not change after toggling light/dark mode
ButNSImage(named: "Image")
simply does not change its appearance after me toggling light/dark mode in System Preferences.
I am sure that the code was invoked because:
nsImgaeView.image = NSImage(named: "Another_Image") // Changes to another image after toggling
Restarting the app does make it change its appearance. I guess it is because the system caches the image after the initial load?