0

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.

WangYudong
  • 4,335
  • 4
  • 32
  • 54
Smikey
  • 8,106
  • 3
  • 46
  • 74
  • Is `GameFont` a custom font? Try to test changing your font color with a fresh SpriteKit project. – WangYudong Sep 20 '15 at 12:18
  • GameFont was a custom font, but I've tried it with @"Arial" and it's still the wrong colour... – Smikey Sep 20 '15 at 12:39
  • I have no problem to set font color with a new project. – WangYudong Sep 20 '15 at 12:42
  • Ok, so this is an issue for projects that have upgraded from Xcode 6? I have found other issues, like flipped nodes, but I can't simply create a new project... – Smikey Sep 20 '15 at 12:48
  • You needn't start a new project, just comment some other code or separate the code that does the font setting in order to narrow down the issue. – WangYudong Sep 20 '15 at 12:58

1 Answers1

0

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...

Smikey
  • 8,106
  • 3
  • 46
  • 74