Below is the code from GameViewController I use to present my GameScene. GameScene comes out respecting the safe areas (iPhone X).
However if I create an SKSprite node, the coords for the upper screen draw into the safe area.
My impression was that would not happen, nor can I find the top and bottom anchors.
p.s. on a side note, I cannot view originalS.frame.width or originalS.frame.height in the debugger, they come out as invalid expressions. yet they don't crash the app.
However if I create an SKSprite node, the coords for the upper screen draw into the safe area.
My impression was that would not happen, nor can I find the top and bottom anchors.
p.s. on a side note, I cannot view originalS.frame.width or originalS.frame.height in the debugger, they come out as invalid expressions. yet they don't crash the app.
Code Block class GameViewController: UIViewController { private let myView : UIView = { let myView = UIView() myView.translatesAutoresizingMaskIntoConstraints = false myView.backgroundColor = .clear return myView }() private func addConstraints(){ var constraints = [NSLayoutConstraint]() constraints.append(myView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor)) constraints.append(myView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor)) constraints.append(myView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor)) constraints.append(myView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor)) NSLayoutConstraint.activate(constraints) } let logo = UIImage(named: "startup") override func viewDidLoad() { super.viewDidLoad() view.addSubview(myView) addConstraints() if let view = self.view as! SKView? { myGlobalVars.widthPixels = UIScreen.main.nativeBounds.width myGlobalVars.heightPixels = UIScreen.main.nativeBounds.height myGlobalVars.widthPoints = UIScreen.main.bounds.width myGlobalVars.heightPoints = UIScreen.main.bounds.height originalS = myView originalS.backgroundColor = .clear originalS.translatesAutoresizingMaskIntoConstraints = false originalS.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor).isActive = true originalS.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 0).isActive = true originalS.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor).isActive = true originalS.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor , constant: -0).isActive = true var scene : GameScene! DispatchQueue.main.async { scene = GameScene(size: CGSize(width: originalS.frame.width, height: originalS.frame.height)) scene.anchorPoint = CGPoint(x: 0.0, y: 0.0) scene.backgroundColor = .black scene.scaleMode = .aspectFit myGlobalVars.sceneRect = scene.frame myGlobalVars.gameScene = scene view.isHidden = false view.presentScene(scene) } myGlobalVars.passGo = true view.ignoresSiblingOrder = true view.showsFPS = true view.showsNodeCount = true view.showsPhysics = false } }