Search code examples
iosswiftscreencgrect

How to get window size in swift (including iPad split screen)


I want to get the window bounds as CGRect object. This is my current code:

let screenSize : CGRect = self.view.window?.frame

I found this code on the internet, but sometimes screenSize is nil. Is there any other option?


Solution

  • I've found the answer

    let screenSize : CGRect = self.view.frame