Search code examples
objective-csprite-kitios9uicolorsklabelnode

Setting SKLabelNode font colour appears to be broken in iOS 9


Since the iOS 9 update, setting an SKLabelNode's font colour appears to be broken. Calling this sets text to green!

SKLabelNode *labelNode = [SKLabelNode labelNodeWithFontNamed:GameFont];
[labelNode setFontColor:[UIColor blackColor]];

And setting it to [UIColor whiteColor] turns it yellow... The only way to get white text is to not set the colour at all.

I've tried:

labelNode.color = [UIColor blackColor];
labelNode.colorBlendFactor = 1;

But this doesn't seem to do anything. Anyone else having this problem?

Cheers.


Solution

  • Well I figured it out. It seems that for some reason, certain UIColor methods are just returning the wrong values in iOS9. By using RGB values, it comes out correctly.

    [labelNode setFontColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:1]];
    

    I'm not sure why [UIColor blackColor] apparently works in a new project though...