I use image, this image has two versions for light and dark UIUserInterfaceStyle
, but I need to use the image light version in one UIViewController
when Dark Mode is on. I know I can use tintColor
, but I want to find out if other ways to do this.
How to use Light UIUserInterfaceStyle image version in Dark Mode?
2.1k views Asked by Alexander Khitev At
2
There are 2 answers
2
On
You can opt out of dark mode for a particular view controller by setting the overrideUserInterfaceStyle property in viewDidLoad function. Sample snippet as follows.
override func viewDidLoad() {
super.viewDidLoad()
// Always adopt a light interface style.
overrideUserInterfaceStyle = .light
}
To opt out dark mode for your image view you can set as follows.
imageview. overrideUserInterfaceStyle = .light
You can check out further about opt out of dark mode from the link below. Hope it helps.
Subramanian's answer is perfect for this use case.
However, I you really need just the
UIImage
in a different style, you can do the following: