Friday, June 10, 2016

Finding out whether device is iPad Pro

Both iPad and iPad Pro fall into same family size (Rw and Rh) sometimes we will be in need of customising only for iPad Pro.In such scenarios we need to have short cuts to determine whether device is iPad Pro.

Following snippet will help you out:

#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
#define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
#define IS_IPAD_PRO_1366 (IS_IPAD && MAX(SCREEN_WIDTH,SCREEN_HEIGHT) == 1366.0)
#define IS_IPAD_PRO_1024 (IS_IPAD && MAX(SCREEN_WIDTH,SCREEN_HEIGHT) == 1024.0)