如何识别是iPhone X 的宏定义

废话不说,直接上代码:

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)

你可能感兴趣的:(如何识别是iPhone X 的宏定义)