出于某种原因,当我尝试创建一个GameScene并尝试根据此处的建议将其扩展到iPad时。我的视图周围有黑色边框:
这是我的代码:
import UIKit
import SpriteKit
class GameViewController: UIViewController {
var scene: GameScene!
override func viewDidLoad() {
super.viewDidLoad()
let skView = view as! SKView
skView.multipleTouchEnabled = false;
scene = GameScene(size: skView.bounds.size)
scene.scaleMode = .ResizeFill
scene.backgroundColor = UIColor.whiteColor()
print(scene.frame.size)
skView.presentScene(scene)
}
override func shouldAutorotate() -> Bool {
return true
}
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
if UIDevice.currentDevice().userInterfaceIdiom == .Pad {
return .Landscape
} else {
return .AllButUpsideDown
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Release any cached data, images, etc that aren't in use.
}
override func prefersStatusBarHidden() -> Bool {
return true
}
}
和此:
import SpriteKit
class GameScene: SKScene {
override func didMoveToView(view: SKView) {
/* Setup your scene here */
let testLabel = SKLabelNode(text: "Hello World!")
testLabel.position = CGPoint(x: size.width/2, y: size.height/2)
testLabel.fontColor = UIColor.blueColor()
addChild(testLabel)
}
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
/* Called when a touch begins */
}
override func update(currentTime: CFTimeInterval) {
/* Called before each frame is rendered */
}
}
如何摆脱视角周围的黑色边框?