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

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.

I am also having this issue. I have tried changing color and tints of the UIImage, SKTexture, and SKSpriteNode. I have also tried UIImage configurations with no success.

Same issue here. Not only is the image on iOS always black when on macOS it displays as expected, but on iOS some images are also displayed with a slightly wrong aspect ratio, as demonstrated by this code:

import SpriteKit
#if os(macOS)
import AppKit
#else
import UIKit
#endif

class GameScene: SKScene {
    
    override func didMove(to view: SKView) {
        let systemImage = "square.and.arrow.up"
        let width = 400.0
        #if os(macOS)
        let image = NSImage(systemSymbolName: systemImage, accessibilityDescription: nil)!.withSymbolConfiguration(.init(hierarchicalColor: .white))!
        let scale = NSScreen.main!.backingScaleFactor
        image.size = CGSize(width: width * scale, height: width / image.size.width * image.size.height * scale)
        #else
        let image = UIImage(systemName: systemImage)!.applyingSymbolConfiguration(.init(pointSize: width))!.applyingSymbolConfiguration(.init(hierarchicalColor: .white))!
        #endif
        let texture = SKTexture(image: image)
        print(image.size, texture.size(), image.size.width / image.size.height)
        let size = CGSize(width: width, height: width / image.size.width * image.size.height)
        addChild(SKSpriteNode(texture: texture, size: size))
    }

}
SKTexture renders SF Symbols image always black
 
 
Q