繁体   English   中英

SKScene中的标签在iPhone 6 / 6plus中没有完全左对齐

[英]Label in SKScene not fully left justified in iPhone 6 / 6plus

我正在努力确保始终在屏幕的左上角显示标签,无论使用哪种设备。

这是我的代码:

override func didMoveToView(view: SKView) {

        var screenSize = UIScreen.mainScreen().bounds
        var screenWidth = screenSize.width
        var screenHeight = screenSize.height


        self.scaleMode = SKSceneScaleMode.AspectFit;
        self.backgroundColor = SKColor.blackColor()
        gameScore = SKLabelNode(fontNamed: "Chalkduster")
        gameScore.text = "Score: 0"
        gameScore.position = CGPointMake(0, self.frame.size.height)
        gameScore.horizontalAlignmentMode = .Left
        gameScore.verticalAlignmentMode = .Top
        gameScore.fontSize = 48
        gameScore.zPosition = 1
        addChild(gameScore)


    }

在所有iPad系列设备上,它都完美地显示在左侧,但是在iPhone 6和6+上,它向右缩进了大约1/2英寸。

任何想法为什么会这样?

谢谢!

我想回答这个问题,以防其他像我这样的初学者陷入困境! 确保阅读纵横比和缩放模式。

我有:

self.scaleMode = SKSceneScaleMode.AspectFit;

但是应该是:

 self.scaleMode = SKSceneScaleMode.Fill;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM