IOS常用宏定义

//打印当前函数信息

#define PRINTMETHOD NSLog(@"\r\n函数名称:=%s\r\n行数:=%d\r\n时间:=%s\r\n日期:=%s",__FUNCTION__,__LINE__,__TIME__,__DATE__)


//高清屏

#define isRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)


//iPhone5

#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)  


//ipad

#define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)  


#define isSimulator (NSNotFound != [[[UIDevice currentDevice] model] rangeOfString:@"Simulator"].location)


//当前系统版本号

#define CurrentSystemVersion ([[UIDevice currentDevice] systemVersion])  


//系统IOS 几的判断

#define IS_IOS(x) ([[UIDevice currentDevice].systemVersion intValue] >= x)


//当前语言

#define CurrentLanguage ([[NSLocale preferredLanguages] objectAtIndex:0])


#if TARGET_OS_IPHONE

//iPhone Device

#endif


#if TARGET_IPHONE_SIMULATOR

//iPhone Simulator

#endif


#if __has_feature(objc_arc)

//compiling with ARC

#else

// compiling without ARC

#endif


//存储对象

#define USER_DEFAULT [NSUserDefaults standardUserDefaults]


//设置图片

#define ImageNamed(_pointer) [UIImage imageNamed:_pointer]


//Image

//可拉伸的图片


#define ResizableImage(name,top,left,bottom,right) [[UIImage imageNamed:name] resizableImageWithCapInsets:UIEdgeInsetsMake(top,left,bottom,right)]

#define ResizableImageWithMode(name,top,left,bottom,right,mode) [[UIImage imageNamed:name] resizableImageWithCapInsets:UIEdgeInsetsMake(top,left,bottom,right) resizingMode:mode]


//file

//读取文件的文本内容,默认编码为UTF-8

#define FileString(name,ext)            [[NSString alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:(name) ofType:(ext)] encoding:NSUTF8StringEncoding error:nil]

#define FileDictionary(name,ext)        [[NSDictionary alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:(name) ofType:(ext)]]

#define FileArray(name,ext)             [[NSArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:(name) ofType:(ext)]]


//输出frame(frame是结构体,没法%@)

#define LOGFRAME(f) NSLog(@"\nx:%f\ny:%f\nwidth:%f\nheight:%f\n",f.origin.x,f.origin.y,f.size.width,f.size.height)

#define LOGBOOL(b)  NSLog(@"%@",b?@"YES":@"NO");

//弹出信息

#define ALERT(msg) [[[UIAlertView alloc] initWithTitle:nil message:msg delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil] show]


//App

#define kApp ((AppDelegate *)[UIApplication sharedApplication].delegate)

#define kNav ((AppDelegate *)[UIApplication sharedApplication].delegate.navigationController)


//color

#define RGB(r, g, b)             [UIColor colorWithRed:((r) / 255.0) green:((g) / 255.0) blue:((b) / 255.0) alpha:1.0]

#define RGBAlpha(r, g, b, a)     [UIColor colorWithRed:((r) / 255.0) green:((g) / 255.0) blue:((b) / 255.0) alpha:(a)]



//设备屏幕尺寸

#define kScreen_Height   ([UIScreen mainScreen].bounds.size.height)

#define kScreen_Width    ([UIScreen mainScreen].bounds.size.width)

#define kScreen_Frame    (CGRectMake(0, 0 ,kScreen_Width,kScreen_Height))

#define kScreen_CenterX  kScreen_Width/2

#define kScreen_CenterY  kScreen_Height/2


//应用尺寸(不包括状态栏,通话时状态栏高度不是20,所以需要知道具体尺寸)

#define kContent_Height   ([UIScreen mainScreen].applicationFrame.size.height)

#define kContent_Width    ([UIScreen mainScreen].applicationFrame.size.width)

#define kContent_Frame    (CGRectMake(0, 0 ,kContent_Width,kContent_Height))

#define kContent_CenterX  kContent_Width/2

#define kContent_CenterY  kContent_Height/2


//拨打电话

#define canTel                 ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tel:"]])

#define tel(phoneNumber)       ([[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",phoneNumber]]])

#define telprompt(phoneNumber) ([[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"telprompt:%@",phoneNumber]]])


//打开URL

#define canOpenURL(appScheme) ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:appScheme]])

#define openURL(appScheme) ([[UIApplication sharedApplication] openURL:[NSURL URLWithString:appScheme]])


//设置字体,字号

// For text, messages, etc

#define DEFAULT_FONTSIZE    15

#define DEFAULT_FONT(s)     [UIFont fontWithName:@"ArialMT" size:s]

#define DEFAULT_BOLDFONT(s) [UIFont fontWithName:@"Arial-BoldMT" size:s]


// For table cells

#define CELL_FONTSIZE    16

#define CELL_FONT(s)     [UIFont fontWithName:@"Helvetica-Oblique" size:s]

#define CELL_BOLDFONT(s) [UIFont fontWithName:@"Helvetica-BoldOblique" size:s]





#ifdef DEBUG

//Debug模式

//...

#else

//发布模式

//...

//屏蔽NSLog

#define NSLog(...) {};

#endif



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值