SKTexture renders SF Symbols image always black

Hi,

I'm creating a SF Symbols image like this:

var img = UIImage(systemName: "x.circle" ,withConfiguration: symbolConfig)!.withTintColor(.red)

In the debugger the image is really red.

and I'm using this image to create a SKTexture:


 let shuffleTexture = SKTexture(image: img)

The texture image is ALWAYS black and I have no idea how to change it's color. Nothing I've tried so far works.

Any ideas how to solve this?

Thank you!

Best Regards,

Frank

Replies

After experimenting with the Spritekit-Scene-Editor in XCode it turned out that, when the SKTexture Color is black, setting the color in the SKSpriteNode with Blendfactor 1.0 and BlendNode "Alpha" has no effect. When the SKTextureColor is white it works as desired.

The problem is that when I create the SKTexture programmatically from an UIImage which is based on a SF Symbols character it is ALWAYS black. No idea how to get it white:

    shuffleSymbolNode = SKSpriteNode(texture: shuffleTexture, color: .white , size: centerRect.size)
    shuffleSymbolNode!.blendMode = .alpha
    shuffleSymbolNode!.color = SKColor.white
    shuffleSymbolNode!.colorBlendFactor = 1.0

has NO effect - the SKSpriteNode is still black.