我正在使用 SKLabelNode 来显示通用游戏的分数。字体大小对于 iPhone 来说是完美的,但对于 iPad 来说自然需要更大。我想知道是否有任何方法可以更改 iPad 的字体大小?我在 didMoveToView 中试过这个:(可能完全错误,但我唯一能想到的)
if UIDevice.currentDevice().userInterfaceIdiom == .Pad {
scoreLabel.fontSize = 45 }
这没有用。有任何想法吗??注意:如果这有什么不同,我使用的是自定义字体而不是苹果字体。
let scoreLabel = SKLabelNode(fontNamed: "DS Digital")
scoreLabel.position = CGPoint(x: size.width * 0.07, y: size.height * 0.9)
scoreLabel.text = "0"
scoreLabel.fontSize = 15
addChild(scoreLabel)
scoreLabel.zPosition = 3
let waitScore = SKAction.waitForDuration(1.0) //add score every second
let incrementScore = SKAction.runBlock ({
++self.score
self.scoreLabel.text = "\(self.score)"}) //update score label with score
self.runAction(SKAction.repeatActionForever(SKAction.sequence([waitScore,incrementScore])))