iOS 用到的宏

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iOS 用到的宏相关的知识,希望对你有一定的参考价值。

一些常用的宏判断,遇到了我在更新,一步一步坚持

判断系统版本的

#define ios_Syteam [[[UIDevice currentDevice] systemVersion] floatValue]

 

颜色

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


//获取屏幕 宽度、高度  

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

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


//获取当前语言  

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


// rgb颜色转换(16进制->10进制)  

#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

重写NSLog,Debug模式下打印日志和当前行数
#if DEBUG
#define NSLog(FORMAT, ...) fprintf(stderr,"\nfunction:%s line:%d content:%s\n", __FUNCTION__, __LINE__, [NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
#else
#define NSLog(FORMAT, ...) nil
#endif

本文出自 “11204872” 博客,请务必保留此出处http://11214872.blog.51cto.com/11204872/1754100

以上是关于iOS 用到的宏的主要内容,如果未能解决你的问题,请参考以下文章

iOS小菜那些年写过的宏文件

Cocoa中常用的宏定义

iOS LLVM 中的宏定义

iOS开发中常用的宏

iOS开发中常用的宏

ios开发常用的宏