配置PCH文件及常用宏

配置PCH文件路徑

$(SRCROOT)/$(PRODUCT_NAME)/PrefixHeader.pch


PCH文件


#ifdef __OBJC__

//導入頭文件


//宏定義
/**獲取系統對象*/
#define kApplication [UIApplication sharedApplication]

#define kAppWindow [UIApplication sharedApplication].delegate.window

#define kAppDelegate [AppDelegate shareAppDelegate]

#define kRootViewController [UIApplication sharedApplication].delegate.window.rootViewController

#define kUserDefaults [NSUserDefaults standardUserDefaults]

#define kNotificationCenter [NSNotificationCenter defaultCenter]

/**iphone6的*/
#define Iphone6ScaleWidth KScreenWidth/375.0
#define Iphone6ScaleHeight KScreenHeight/667.0

/**根據ip6的屏幕來拉伸*/
#define kRealValue(with) ((with)*(KScreenWidth/375.0f))

/**強弱引用*/
#define kWeakSelf(type) __weak typeof(type)weak##type = type;

#define kStrongSelf(type)__strong typeof(type)type = weak##type;

//View圓角和加邊框

#define ViewBorderRadius(View,Radius,Width,Color)\
\
[View.layer setCornerRadius:(Radius)];\
[View.layer setMasksToBounds:YES];\
[View.layer setBorderWidth:(Width)];\
[View.layer setBorderColor:[Color CGColor]]

/**屏幕的Bounds*/
#define SCREEN_RECT  [[UIScreen mainScreen] bounds]

/**屏幕的高度*/
#define SCR_HEIGHT [[UIScreen mainScreen]bounds].size.height

/**屏幕的寬度*/
#define SCR_WIDTH  [[UIScreen mainScreen]bounds].size.width

/**tabBar高度*/
#define TABBAR_HEIGHT 49

/**navBar高度*/
#define NAVBAR_HEIGHT ([[[UIDevice currentDevice] systemVersion] floatValue] < 7.0 ? (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? 64:44):(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? 64:64))

/**當前版本號*/
#define CURRENT_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]

/**大於等於7.0的ios版本*/
#define iOS7_OR_LATER SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")

/**大於等於8.0的ios版本*/
#define iOS8_OR_LATER SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")



//自定義log輸出
#ifdef DEBUG  // 在開發階段

#define NSLog(fat, ...) NSLog((@"%s [Line %d] " fat), __FUNCTION__, __LINE__, ##__VA_ARGS__)

#else  // 非開發階段, 也就意味着  打包上架階段  releas

#define NSLog(...)

#endif

#endif

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章