导读
在Header-Prefix.pch文件里面定义了一些屏幕尺寸的宏定义。
[Objective-C] 纯文本查看 复制代码 #define Get_Real_Px()
//屏幕尺寸
#define ScreenFrame [[UIScreen mainScreen] bounds]
#define ScreenHeight [UIScreen mainScreen].bounds.size.height
#define ScreenWidth [UIScreen mainScreen].bounds.size.width
//适配iphone x 顶部和底部的安全区域
#define SafeAreaTopHeight (ScreenHeight == 812.0 ? 88 : 64)
#define SafeAreaBottomHeight (ScreenHeight == 812.0 ? 34 : 0)
//适配后的可见屏幕的高度
#define FrameHeight [UIScreen mainScreen].bounds.size.height - SafeAreaTopHeight - SafeAreaBottomHeight
//获得当前屏幕宽与6的屏宽比例
#define RATIO_W [UIScreen mainScreen].bounds.size.width/375
//获得当前屏幕高与6的屏高比例
#define RATIO_H [UIScreen mainScreen].bounds.size.height/667
//同比例的x、y、width、height
#define X(x) x*RATIO_W
#define Y(y) y*RATIO_H
#define Width(width) width*RATIO_W
#define Height(height) height*RATIO_H
//6.iphone型号判断
#define ScreenHeight_480 ScreenHeight == 480 //iphone4、4s
#define ScreenHeight_568 ScreenHeight == 568 //iphone5、5s
#define ScreenHeight_667 ScreenHeight == 667 //iphone6、6s
#define ScreenHeight_1104 ScreenHeight == 1104 //iphone6plus
#define ScreenHeight_1218 ScreenHeight == 1218 //iphone X
框架源码下载
|