废话不说,直接上代码:
OC
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define SCREEN_MAX_LENGTH (MAX(SCREEN_WIDTH, SCREEN_HEIGHT))
#define IS_IPHONE_iPX (IS_IPHONE && SCREEN_MAX_LENGTH > 736.0)
Swift
let IS_IPHONE = (UI_USER_INTERFACE_IDIOM() == .phone)
let SCREEN_MAX_LENGTH = max(SCREEN_WIDTH, SCREEN_HEIGHT)
let IS_IPHONE_iPX = (IS_IPHONE && SCREEN_MAX_LENGTH > 736.0)