uiscreen
UIScreen MainScreen Bounds returning wrong size
Apparently, iOS relies solely on the presence of a launch image in the resolution of an iPhone 5+ in order to let the app run in that resolution. There are two solutions to this problem: 1. Use Asset Catalogs When you create a new project, there’s this thing called an asset catalog which stores your … Read more
What is the difference between -nativeScale and -scale on UIScreen in iOS8+?
Both scale and nativeScale tell you how many pixels a point corresponds to. But keep in mind that points are rendered to an intermediate buffer of pixels, which is then resized to match the screen resolution. So, when we ask, “1 pt corresponds to how many pixels?” it might mean intermediate pixels (scale) or the … Read more
How to get screen size using code on iOS?
You can use the bounds property on an instance of UIScreen: CGRect screenBound = [[UIScreen mainScreen] bounds]; CGSize screenSize = screenBound.size; CGFloat screenWidth = screenSize.width; CGFloat screenHeight = screenSize.height; Most people will want the main screen; if you have a device attached to a TV, you may instead want to iterate over UIScreens and get … Read more
How to get device width and height?
I haven’t tried but it should be.. var bounds = UIScreen.main.bounds var width = bounds.size.width var height = bounds.size.height
Is [UIScreen mainScreen].bounds.size becoming orientation-dependent in iOS8?
Yes, it’s orientation-dependent in iOS8, not a bug. You could review session 214 from WWDC 2014 for more info: “View Controller Advancements in iOS 8” Quote from the presentation: UIScreen is now interface oriented: [UIScreen bounds] now interface-oriented [UIScreen applicationFrame] now interface-oriented Status bar frame notifications are interface-oriented Keyboard frame notifications are interface-oriented
Detect Retina Display
In order to detect the Retina display reliably on all iOS devices, you need to check if the device is running iOS4+ and if the [UIScreen mainScreen].scale property is equal to 2.0. You CANNOT assume a device is running iOS4+ if the scale property exists, as the iPad 3.2 also contains this property. On an … Read more