Pch文件

作用:程序在运行之前首先读取该文件中的代码,可以在该文件中定义一些整个工程都可以直接读取的符号!

添加步骤:

//屏幕的宽和高
#define SCR_W    [UIScreen mainScreen].bounds.size.width
#define SCR_H    [UIScreen mainScreen].bounds.size.height

//判断是否是3.5寸屏(320px * 480px)
#define SCR_3_5 (SCR_W == 320 && SCR_H == 480)
//4寸屏(640px * 1136px)
#define SCR_4 (SCR_W == 320 && SCR_H == 568)
//4.7寸屏(750px * 1334px)
#define SCR_4_7 (SCR_W == 375 && SCR_H == 667)
//5.5寸屏(1242px * 2208px)
#define SCR_5_5 (SCR_W == 414 && SCR_H == 736)
// 苹果X (1125px * 2436px)
#define SCR_x (SCR_W == 375 && SCR_H == 812)
// 苹果XR (828px * 1792px)
#define SCR_XR (SCR_W == 414 && SCR_H == 896)
// 苹果XS max (1242px * 2688px)
#define SCR_XS_max (SCR_W == 414 && SCR_H == 896)


//状态栏高度
#define StatusBarHeight (SCR_H <= 736? 20:44)
//导航条高度
#define NavigationItemHeight 44.0
//顶部条高度
#define TopBarHeight (StatusBarHeight + NavigationItemHeight)
![屏幕快照 2018-11-16 下午6.59.15.png](https://upload-images.jianshu.io/upload_images/14737207-1918be654447d8f2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

你可能感兴趣的:(Pch文件)