【发布时间】:2016-03-28 03:38:05
【问题描述】:
每次我在模拟器中运行我的应用程序时,视图比例总是为 768,1024,你如何将其更改为 1024,768。这是默认尺寸代码 类 GameViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
if let scene = GameScene(fileNamed:"GameScene") {
// Configure the view.
let skView = self.view as! SKView
skView.showsFPS = true
skView.showsNodeCount = true
/* Sprite Kit applies additional optimizations to improve
rendering performance */
skView.ignoresSiblingOrder = true
/* Set the scale mode to scale to fit the window */
scene.scaleMode = .AspectFill
skView.presentScene(scene)
}
}
【问题讨论】:
-
scene.size = ...并且您可以将代码从上面的 viewDidLoad 移动到 viewWillLayoutSubviews 或 viewDidAppear...stackoverflow.com/a/26266857/1702413 -
将它放入 ViewWillLayoutSubviews 是没有意义的。
-
你只是想改变屏幕方向吗?