小编phu*_*gho的帖子

iOS如何通过宏检测iPhone X,iPhone 6 plus,iPhone 6,iPhone 5,iPhone 4?

如何通过宏检测设备模型?我曾经使用过这样的东西但模拟器上的结果总是IS_IPHONE_5

#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_IPHONE_5 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 568.0)
#define IS_IPHONE_6 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 667.0)
#define IS_IPHONE_6PLUS (IS_IPHONE && [[UIScreen mainScreen] nativeScale] == 3.0f)
#define IS_IPHONE_6_PLUS (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 736.0)
#define IS_RETINA ([[UIScreen mainScreen] scale] == 2.0)  
Run Code Online (Sandbox Code Playgroud)

iphone macros detect

110
推荐指数
9
解决办法
8万
查看次数

标签 统计

detect ×1

iphone ×1

macros ×1