iOS-05-常用的宏总结

作者: 小东门儿 | 来源:发表于2016-07-22 12:05 被阅读147次

中文字体

#define CHINESE_FONT_NAME @"Heiti SC"

App Frame Height&Width

#define App_Frame_Height [[UIScreen mainScreen] applicationFrame].size.height
#define App_Frame_Width [[UIScreen mainScreen] applicationFrame].size.width

获取View的属性

#define GetViewWidth(view) view.frame.size.width
#define GetViewHeight(view) view.frame.size.height
#define GetViewX(view) view.frame.origin.x
#define GetViewY(view) view.frame.origin.y

MainScreen Height&Width

#define Main_Screen_Height [[UIScreen mainScreen] bounds].size.height
#define Main_Screen_Width [[UIScreen mainScreen] bounds].size.width

MainScreen bounds

#define Main_Screen_Bounds [[UIScreen mainScreen] bounds]

导航栏高度

#define TopBarHeight 64.5

字体大小(常规/粗体)

#define BOLDSYSTEMFONT(FONTSIZE)[UIFont boldSystemFontOfSize:FONTSIZE]
#define SYSTEMFONT(FONTSIZE) [UIFont systemFontOfSize:FONTSIZE]
#define FONT(NAME, FONTSIZE) [UIFont fontWithName:(NAME) size:(FONTSIZE)]

当前版本

#define FSystemVersion ([[[UIDevice currentDevice] systemVersion] floatValue])
#define DSystemVersion ([[[UIDevice currentDevice] systemVersion] doubleValue])
#define SSystemVersion ([[UIDevice currentDevice] systemVersion])

是否IOS7

#define isIOS7 ([[[UIDevice currentDevice]systemVersion]floatValue] >= 7.0)

是否IOS6

#define isIOS6 ([[[UIDevice currentDevice]systemVersion]floatValue] < 7.0)

是否IOS8

#define isIOS8 ([[[UIDevice currentDevice]systemVersion]floatValue] >=8.0)

是否iPad

#define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)

是否空对象

#define IS_NULL_CLASS(OBJECT) [OBJECT isKindOfClass:[NSNull class]]

色值

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

#define HEXCOLOR(hex) [UIColor colorWithRed:((float)((hex & 0xFF0000) >> 16)) / 255.0 green:((float)((hex & 0xFF00) >> 8)) / 255.0 blue:((float)(hex & 0xFF)) / 255.0 alpha:1]

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

App版本号

#define appMPVersion [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]

AppDelegate对象

#define AppDelegateInstance [[UIApplication sharedApplication] delegate]

获取图片资源

#define GetImage(imageName) [UIImage imageNamed:[NSString stringWithFormat:@"%@",imageName]]

在Main线程上运行

#define DISPATCH_ON_MAIN_THREAD(mainQueueBlock)dispatch_async(dispatch_get_main_queue(), mainQueueBlock);

在Global Queue上运行

#define DISPATCH_ON_GLOBAL_QUEUE_HIGH(globalQueueBlocl) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), globalQueueBlocl);
#define DISPATCH_ON_GLOBAL_QUEUE_DEFAULT(globalQueueBlocl) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), globalQueueBlocl);
#define DISPATCH_ON_GLOBAL_QUEUE_LOW(globalQueueBlocl) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), globalQueueBlocl);
#define DISPATCH_ON_GLOBAL_QUEUE_BACKGROUND(globalQueueBlocl) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), globalQueueBlocl);

DDLog等级

#ifdef DEBUG static const int ddLogLevel = LOG_LEVEL_VERBOSE;#else static const int ddLogLevel = LOG_LEVEL_ERROR;#endif

相关文章

  • iOS-05-常用的宏总结

    中文字体 #define CHINESE_FONT_NAME @"Heiti SC" App Frame Heig...

  • iOS开发常用的工具类和宏定义

    iOS开发常用的工具类和宏定义 开发总结的工具类和宏 https://github.com/xiaoChen66...

  • iOS开发中常用到的宏

    大家都是知道使用宏不仅方便,而且可以提高开发效率。下面总结了iOS开发过程中的一些常用宏。

  • excel-vlookup多条件查询

    不常用excel公式,宏这块内容,用到了Excel公式进行计算,还是写个小总结,记录我不常用但比较好用的公式~~~...

  • ios常用的小宏宏

    写点常用的宏,有什么需要补充的给我留言哦 新加iphoneX的小宏宏 常用的Block解循环。 版本号获取 常用设...

  • iOS开发常用的宏定义

    大家都是知道开发中使用宏不仅方便,而且可以提高开发效率, 代码清晰易懂。下面我总结了我在做iOS开发时的一些常用宏...

  • 2021-12-21 常用宏

    一些常用宏 附:总结 状态栏、导航栏 和 tabbar 高度[https://www.jianshu.com/p/...

  • oc代码规范之宏定义

    常用的宏: 设备相关的宏: 系统相关的宏: 单例

  • 常用宏

    常用宏

  • iOS 开发常用宏

    大家都是知道使用宏不仅方便,而且可以提高开发效率。下面总结了iOS开发过程中的一些常用宏,会持续的往里面添加。 /...

网友评论

    本文标题:iOS-05-常用的宏总结

    本文链接:https://www.haomeiwen.com/subject/dmlijttx.html