美文网首页
iOS判断设备类型常用宏定义

iOS判断设备类型常用宏定义

作者: 霜之幽语 | 来源:发表于2017-11-01 14:46 被阅读132次
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)  
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)  
#define IS_RETINA ([[UIScreen mainScreen] scale] >= 2.0)  
  
#define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)  
#define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)  
#define SCREEN_MAX_LENGTH (MAX(SCREEN_WIDTH, SCREEN_HEIGHT))  
#define SCREEN_MIN_LENGTH (MIN(SCREEN_WIDTH, SCREEN_HEIGHT))  
  
#define IS_IPHONE_4_OR_LESS (IS_IPHONE && SCREEN_MAX_LENGTH < 568.0)  
#define IS_IPHONE_5 (IS_IPHONE && SCREEN_MAX_LENGTH == 568.0)  
#define IS_IPHONE_6 (IS_IPHONE && SCREEN_MAX_LENGTH == 667.0)  
#define IS_IPHONE_6P (IS_IPHONE && SCREEN_MAX_LENGTH == 736.0)  

相关文章

网友评论

      本文标题:iOS判断设备类型常用宏定义

      本文链接:https://www.haomeiwen.com/subject/gmqgpxtx.html