Images in Dark Mode

I’ve got an app that uses transparent PNGs as icons on views. They’re just black on transparent but don’t display properly in Dark Mode.

Do I need to have a second set of images for Dark Mode with the black changed to white?

Since IsDarkMode doesn’t appear to be available in iOS, how does one control this?

convert the “image” to become the mask layer , then you can fill the top layer with any color you want at run time

This is how iOS does the icons on the Tab and Toolbars

From iOSDesignExtensions: https://github.com/jkleroy/iOSDesignExtensions

[code]Protected Function ImageWithMaskXC(image As iOSImage) as iOSImage

//Creates an image that will draw using the current Fillcolor

Declare Function imageWithRenderingMode lib “UIKit.framework” selector “imageWithRenderingMode:” (id as ptr, RenderingMode as Integer) as ptr

Return iOSImage.FromHandle(imageWithRenderingMode(image.Handle, 2))
End Function[/code]

You don’t have to go though all that. Just use the new IosImage.SystemImage and pass a non-existent name in the first parameter, set the ColorGroup parameter to use the colors you want in light and dark mode and pass the black image in as the fallback image. It’ll automatically colorize your image based on its alpha using the specified ColorGroup.

http://documentation.xojo.com/api/deprecated/iosimage.html#iosimage-systemimage

seems this would be a good place for an overload like

iOSImage.SystemImage(templateImage as iOSImage, size as Double, weight as iOSImage.SystemImageWeights = SystemImageWeights.Regular, templateColor as ColorGroup = Nil) As iOSImage

rather than passing a bogus parameter for the name

Thanks, this works:

If System.Version >= "13" Then WorldImageView.Image = iOSImage.SystemImage("nil",0,iosimage.SystemImageWeights.Unspecified,ImageColor,WorldIcon) Else WorldImageView.Image = WorldIcon End If
But on iOS 13, when not in Dark Mode, the image has tiny dark spots in each of the 4 corners. I’ve checked the image, and there’s nothing there, and the image works fine in Dark Mode and in iOS < 13. The ColorGroup is the one Named “Label”.

[quote=474300:@Art Gorski]Thanks, this works:

If System.Version >= "13" Then WorldImageView.Image = iOSImage.SystemImage("nil",0,iosimage.SystemImageWeights.Unspecified,ImageColor,WorldIcon) Else WorldImageView.Image = WorldIcon End If
But on iOS 13, when not in Dark Mode, the image has tiny dark spots in each of the 4 corners. I’ve checked the image, and there’s nothing there, and the image works fine in Dark Mode and in iOS < 13. The ColorGroup is the one Named “Label”.[/quote]
What does the WorldIcon look like?

I tried a different icon and it displays just fine, so it must be something with that image. I’ll dork with it and not take up more time here. Thanks.