Question: I tried `[[UIScreen mainScreen] bounds]` to get the screen size of a resizable iPhone on `Xcode 6` simulator. But it doesn't take into account the new screen width and screen height I assign to it.

Is there a better way to get the screen size? Even if I set the screen size to **320x800** the `[[UIScreen mainScreen] bounds]` returns me `(CGRect) $0 = origin=(x=0, y=0) size=(width=768, height=1024)`

![enter image description here](https://i.stack.imgur.com/y0k9k.png)

Answer: 
In Swift 4.0, 3.0 

```
let screenRect:CGRect = UIScreen.main.bounds

```
This gets in iOS8 and iOS9. Not sure about 7 haven't tested:

```
var screenWidth: CGFloat {
    if UIInterfaceOrientationIsPortrait(screenOrientation) {
        return UIScreen.mainScreen().bounds.size.width
    } else {
        return UIScreen.mainScreen().bounds.size.height
    }
}
var screenHeight: CGFloat {
    if UIInterfaceOrientationIsPortrait(screenOrientation) {
        return UIScreen.mainScreen().bounds.size.height
    } else {
        return UIScreen.mainScreen().bounds.size.width
    }
}
var screenOrientation: UIInterfaceOrientation {
    return UIApplication.sharedApplication().statusBarOrientation
}

```

These are included as a standard function in:

<https://github.com/goktugyil/EZSwiftExtensions>