ios 底层

pch文件

2018-11-25  本文已影响0人  weyan

pch文件的作用:

1. 存放公有宏。

2. 存放公有头文件。

3. 自定义log。

pch文件原理:

把pch当中的所有内容拷贝到工程当中的每一个文件。

注意:OC文件对pch文件中的OC自定义的内容识别但对C文件不识别会报错,如果有C文件要做判断,每一个OC文件内部都默认有一个隐式宏:"--OBJC--"。

创建pch文件 设置pch文件

自定义log:

#ifndef PrefixHeader_pch
#define PrefixHeader_pch
#import "Masonry.h"//自动布局
#import "MJRefresh.h"//刷新
#import "AFNetworking.h"//AFN

// 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 IOS_SYSTEM_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]

//设置RGB颜色
#define ERGBColor(r,g,b,a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:a]

//打印设置
#ifdef DEBUG  //如果是调试模式,自定义如下: “...代表多个参数”
#define ELog(...) NSLog(@"%s 第%d行 \n %@\n\n",__func__,__LINE__,[NSString stringWithFormat:__VA_ARGS__])
#else //如果是发布模式,自定义如下
#define ELog(...)
#endif

//屏幕的宽度和高度
#define SCREENWIDTH [[UIScreen mainScreen] bounds].size.width
#define SCREENHEIGHT [[UIScreen mainScreen] bounds].size.height

//状态栏高度
#define kStatusBar_Height kDevice_Is_iPhoneX?44:20
#define kTableView_Height kDevice_Is_iPhoneX?88:64
//等比例适配
#define autoSizeScaleW [[UIScreen mainScreen] bounds].size.width/375
#define autoSizeScaleH [[UIScreen mainScreen] bounds].size.height/667

#endif 
image.png

if语句简洁的写法

if语句简洁的写法
上一篇下一篇

猜你喜欢

热点阅读