Search code examples
iosobjective-cfontssprite-kituicolor

Change font filling color in Sprite Kit


I'm facing a problem using a "open" font with Xcode. My aim is to get a text like the following:

Black stroke / red filling

I tried using this part of code:

// Creates the 'Welcome' label node
SKLabelNode *welcomeLabel; 

welcomeLabel           = [SKLabelNode labelNodeWithFontNamed:@"Welcome-font"];
welcomeLabel.position  = CGPointMake(0, 0);
welcomeLabel.fontSize  = 10.0;
welcomeLabel.fontColor = [UIColor redColor]; // TRY CHANGING COLOR
welcomeLabel.text      = @"Welcome";

[self addChild:welcomeLabel];

but what I get is a red border and a transparent background:

Red border on transparent background

This is my very first time using a font with alpha inside and I don't know how to figure it out! Could someone help me to achieve that? (I am using Xcode 6.3 and the .ttf version of the font)


Solution

  • There is no concept of multi color fonts in iOS. The font itself does not describe the red area in your first image.

    If you have the font in a solid variant, draw that first in red, then the black outline on top.