swift 5: sfsymbols tint color and spritekit

Here’s a minor annoyance. Have you tried changing the color of an SF Symbol and initializing an SKTexture only to have the color change fail? In case you’re unaware, iOS 13 introduced SF Symbols.


These are handy vector graphics for standardized purposes (think using it for an email button, close button, home button, etc). They’re incredibly convenient and consistent with the overall feel of iOS.

In any case, when we tried to add a home button to our iOS game using SpriteKit SKTexture, we noticed the color wouldn’t change. We assume this a bug considering it behaves properly with UIImage.

To cut to the chase, if you’re applying an SF Symbol to an SKTexture and want to change the tint color, the following is a decent work around (although not perfect). Hopefully this gets updated!

        let systemImageName = "house.fill"
        let largeConfig = UIImage.SymbolConfiguration(pointSize: 16, weight:.ultraLight)
        guard let systemImage = UIImage(systemName: systemImageName, withConfiguration: largeConfig)?.withTintColor(UIColor.red) else { return }
        guard let systemImageData = systemImage.pngData() else { return }
        guard let systemImageTinted = UIImage(data: systemImageData) else { return }
        let texture = SKTexture(image: systemImage)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.