pch文件
作用:程序在运行之前首先读取文件中的代码,可以在该文件中定义一些整个工程d都可以直接读取的符号
#ifndef Music_pch
#define Music_pch
// Include any system framework and library headers here that should be included in all compilation units.
// You will also need to set the Prefix Header build setting of one or more of your targets to reference this file.
#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 *2196px)
#define SCR_5_5 (SCR_W==414&&SCR_H==736)
//判断是否是 X 寸屏(1125px *2436px)
#define SCR_X (SCR_W==375&&SCR_H==812)
//判断是否是X_R寸屏(320px *480px)
#define SCR_X_R (SCR_W==414&&SCR_H==896)
//判断是否是X_Max寸屏(1242px *2688px)
#define SCR_X_Max (SCR_w==414&&SCR_H==896)
//状态栏高度
#define StatusBarHeight (SCR_H<=736?20:44)
//导航条高度
#define NavigationItemHeight 44.0
//顶部高度
#define TopBarHeight (StatusBarHeight+NavigationItemHeight)
#endif /* Music_pch */
添加步骤:
新建Pch文件 工程设置-BuildSetting-Prefix Header -¥(SRCROOT)/工程名称/pch文件全称
[图片上传中...(屏幕快照 2018-11-16 上午11.48.28.png-b6301f-1542353480895-0)]