iOS敏捷开发之道,常用的宏定义总结

iOS开发中,直接在pch文件中导入宏定义。在做项目的时候,,直接拿过来使用,可以大幅度提高开发速度。 下面是 个人总结的一些宏定义。如果大家有其他的常用的宏定义,欢迎添加。我会定期更新这个blog…..

话不多说,直接上干货

// 在宏的参数前加上一个#,宏的参数会自动转换成c语言的字符串#define MRKeyPath(objc,keyPath) @(((void)objc.keyPath, #keyPath))//*#define LoadNib(x) [[NSBundle mainBundle] loadNibNamed:@(x) owner:nil options:nil][0]//*//*//////// App Frame#define Application_Frame[[UIScreen mainScreen] applicationFrame]// App Frame Height&Width#define App_Frame_Height[[UIScreen mainScreen] applicationFrame].size.height#define App_Frame_Width[[UIScreen mainScreen] applicationFrame].size.width// MainScreen Height&Width#define Main_Screen_Height[[UIScreen mainScreen] bounds].size.height#define Main_Screen_Width[[UIScreen mainScreen] bounds].size.width// View 坐标(x,y)和宽高(width,height)// 系统控件默认高度/*/#pragma mark – Funtion Method (宏 方法)// PNG JPG 图片路径#define GetImagePathFromBundle(NAME) [[NSBundle mainBundle] pathForResource:[NSString stringWithUTF8String:NAME] ofType:nil]#define GetExtPathFromBundle(NAME, EXT)[[NSBundle mainBundle] pathForResource:(NAME) ofType:(EXT)]// 颜色(RGB)// View 圆角和加边框// 当前版本// 当前语言#define CURRENTLANGUAGE([[NSLocale preferredLanguages] objectAtIndex:0])// 是否Retina屏// 是否iPhone5// 是否iPad#define isPad(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)// UIView – viewWithTag#define VIEWWITHTAG(_OBJECT, _TAG) [_OBJECT viewWithTag : _TAG]// 本地化字符串/** NSLocalizedString宏做的其实就是在当前bundle中查找资源文件名“Localizable.strings”(参数:键+注释) */#define LocalString(x, …)NSLocalizedString(x, nil)/** NSLocalizedStringFromTable宏做的其实就是在当前bundle中查找资源文件名“xxx.strings”(参数:键+文件名+注释) */#define AppLocalString(x, …) NSLocalizedStringFromTable(x, @”someName”, nil)

最有效的资本是我们的信誉,它24小时不停为我们工作。

iOS敏捷开发之道,常用的宏定义总结

相关文章:

你感兴趣的文章:

标签云: