SpriteKit how to get correct screen size

后端 未结 2 1815
猫巷女王i
猫巷女王i 2021-01-05 02:04

I\'ve tried

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

None of them work.

How do I get the correct sc

2条回答
  •  青春惊慌失措
    2021-01-05 02:48

    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
    

提交回复
热议问题