我创建了一个显示高分的标签。我想将单位ft添加到最后,因为分数是距离。我正在使用自定义字体,只需将ft添加到最终结尾的FT结果由于字体大小和字体而变大。我很想知道我是否可以缩小字体大小并将其添加到最后。
这是我到目前为止的代码:
var highscoreLabel:SKLabelNode!
highscoreLabel = SKLabelNode(fontNamed: "Komika Axis")
highscoreLabel.fontSize = 16
highscoreLabel.zPosition = 5
highscoreLabel.fontColor = UIColor.whiteColor()
self.addChild(highscoreLabel)
var highscoreShow = defaults.integerForKey("RegularHighscore")
highscoreLabel.text = "High score: \(highscoreShow)"
// High Score: \(highscoreShow) (ft in a smaller font size)"
我希望以比标签中其他文本更小的字体大小添加ft。
答案 0 :(得分:1)
归因字符串将有助于:
var ftString = NSMutableAttributedString(string:"ft", attributes:[NSFontAttributeName : UIFont(name: "Komika Axis", size: 10.0)])
highscoreLabel.attributedText = NSMutableAttributedString(string:"\(highscoreShow)").appendAttributedString(ftString)