zbz.lvlv zbz.lvlv - 3 months ago 7
iOS Question

SpriteKit how to get correct screen size

I've tried

self.frame.size
self.view!.frame.size
UIScreen.mainScreen().bounds.size


None of them work.

How do I get the correct screen size for the device?

Answer

You can use following swift code to get the screen size.

let displaySize: CGRect = UIScreen.mainScreen().bounds
let displayWidth = displaySize.width
let displayHeight = displaySize.height
Comments