iOS 敏捷开发,常用的宏

来源:互联网 发布:centos 开启ftp端口 编辑:程序博客网 时间:2024/05/04 11:31
在做项目的时候,直接拿过来使用,可以大幅度提高开发速度。 下面是 个人总结的一些宏定义。如果大家有其他的常用的宏定义,欢迎添加。我会定期更新这个blog…..话不多说,直接上干货// 在宏的参数前加上一个#,宏的参数会自动转换成c语言的字符串#define MRKeyPath(objc,keyPath) @(((void)objc.keyPath, #keyPath))//** 加载xib ***********************************************************************************#define LoadNib(x) [[NSBundle mainBundle] loadNibNamed:@(x) owner:nil options:nil][0]//** 沙盒路径 ***********************************************************************************#define PATH_OF_APP_HOME    NSHomeDirectory()#define PATH_OF_TEMP        NSTemporaryDirectory()#define PATH_OF_DOCUMENT    [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]//** DEBUG LOG *********************************************************************************#ifdef DEBUG#define MRLog( s, ... ) NSLog( @"< %@:(%d) > %@", [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )#else#define MRLog( s, ... )#endif//** 获得当前的 年 月 日 时 分 秒 *****************************************************************************#define  CurrentSec [[NSCalendar currentCalendar] component:NSCalendarUnitSecond fromDate:[NSDate date]]#define  CurrentMin [[NSCalendar currentCalendar] component:NSCalendarUnitMinute fromDate:[NSDate date]]#define  CurrentHour [[NSCalendar currentCalendar] component:NSCalendarUnitHour fromDate:[NSDate date]]#define  CurrentDay  [[NSCalendar currentCalendar] component:NSCalendarUnitDay fromDate:[NSDate date]]#define  CurrentMonth [[NSCalendar currentCalendar] component:NSCalendarUnitMonth fromDate:[NSDate date]]#define  CurrentYear [[NSCalendar currentCalendar] component:NSCalendarUnitYear fromDate:[NSDate date]]//** 角度转换成弧度 ******************************************************************************************#define  ANGEL(x) (x)/180.0 * M_PI//* Frame (宏 x, y, width, height)**************************************************************************// 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)#define ViewxPos(v)                 (v).frame.origin.x#define ViewyPos(v)                 (v).frame.origin.y#define ViewWidth(v)                (v).frame.size.width#define ViewHeight(v)               (v).frame.size.height#define MinFrameX(v)                 CGRectGetMinX((v).frame)#define MinFrameY(v)                 CGRectGetMinY((v).frame)#define MidFrameX(v)                 CGRectGetMidX((v).frame)#define MidFrameY(v)                 CGRectGetMidY((v).frame)#define MaxFrameX(v)                 CGRectGetMaxX((v).frame)#define MaxFrameY(v)                 CGRectGetMaxY((v).frame)// 系统控件默认高度#define kStatusBarHeight        (20.f)#define kTopBarHeight           (44.f)#define kBottomBarHeight        (49.f)#define kCellDefaultHeight      (44.f)#define kEnglishKeyboardHeight  (216.f)#define kChineseKeyboardHeight  (252.f)

判断不同版本执行不同方法的宏

#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_7_0ios7以上的#else// iPhone OS SDK 7.0 之前版本的处理#endif
0 0
原创粉丝点击