As the title states - I would like to make my SKLabelNode
bold programmatically.
How do I go about this?
As the title states - I would like to make my SKLabelNode
bold programmatically.
How do I go about this?
For SKLabelNode's you need to use:
var labelNode = SKLabelNode()
labelNode = SKLabelNode(fontNamed: "AvenirNext-Bold")
or
var labelNode = SKLabelNode()
labelNode.fontName = "AvenirNext-Bold"
You can't set the SKLabelNode itself to bold. You have to use a Bold Font.
But if you want to use a custom font, you have to use one which is available in bold:
skLabel.fontName = "YourFontName-Bold"
skLabel.fontSize = 14
To get all fonts which are available on iOS check this site: http://iosfonts.com/
Here's a little extension for SKLabelNode. Allows you to toggle between bold and non-bold. Return value tells if it is currently set to bold.
extension SKLabelNode
{
func toggleBold() -> Bool
{
if var range = self.fontName.rangeOfString("-Bold")
{
self.fontName = self.fontName.substringToIndex(range.startIndex)
return false
}
else
{
self.fontName = self.fontName + "-Bold"
return true
}
}
}
Use font property of UILabel
label.font = UIFont(name:"HelveticaNeue-Bold", size: 16.0)
or use default system font to bold text
lable.font = UIFont.boldSystemFontOfSize(16.0)