Last Updated: February 25, 2016
·
1.162K
· ecamacho

Category to detect if an iPhone has a 4" screen (is an iPhone5)

It's better to use AutoLayout to adapt the screens of your app to the iPhone 5, but for those legacy apps that can not be fully migrated to this new API you can use this snippet to detect if the device is an iPhone 5 and adjust the objects in the screen.

@implementation UIDevice (ScreenSizeAdittions)

  • (BOOL)has4InchesScreen { CGRect screenBounds = [[UIScreen mainScreen] bounds]; return screenBounds.size.height == 568.f; }

@end