#define后面一般不加;

宏里面用#argc,是要取argc的值

按比例拉伸??在iPhone6尺寸应该是什么样的高度!

#define DIMENSION_SELF_ADAPT(width, height)\

(width > 0 ? height * kScreenWidth / width : 0)

#define DIMENSION_SELF_ADAPT_375(height) DIMENSION_SELF_ADAPT(375, height)

宏定义

#ifndef MGMacro_h

#define MGMacro_h

……

#endif /* MGMacro_h */

颜色宏

/************ 随机颜色 ************/

#define kRandomColor [UIColor colorWithRed:arc4random_uniform(255)/255.0 green:arc4random_uniform(255)/255.0 blue:arc4random_uniform(255)/255.0 alpha:1.0]

// rgb颜色转换(十六进制)

#define kColorWithHex(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]

#define kColorWithRGB(R,G,B) [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:1.0]

#define kColorWithRGBA(R,G,B,A) [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:A]

尺寸宏

/************ 屏幕尺寸 ************/

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

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

#define STATUS_HEIGHT [[UIApplication sharedApplication] statusBarFrame].size.height

#define StatusBar_HEIGHT 20

#define NavigationBar_HEIGHT 44

#define NavigationBarIcon 20

#define TabBar_HEIGHT 49

#define TabBarIcon 30

// 获取view的frame属性

#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

工具宏

/************ 角度转弧度 ************/

#define kDegrees2Radian(x) (M_PI * (x) / 180.0)

//弧度转角度

#define kRadian2Degrees(radian) (radian * 180.0) / (M_PI)

// 去掉首尾空格

#define TRIM(tempStr) [tempStr stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]

// 获取图片资源

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

// 读取本地图片

#define kLoadImage(file,ext) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle]pathForResource:file ofType:ext]]

打印宏

/************ 自定义NSLog ************/

#ifdef DEBUG

#define MGLog(...) NSLog(__VA_ARGS__)

#else

#define MGLog(...)

#endif

// 打印方法名

#define MGLogFunc MGLog(@"%s",__FUNCTION__);

设备宏

/************ APP版本号 ************/

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

// APP名称

#define kAppName [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]

// 获取当前语言

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

// 判断是否为iPhone

#define kISiPhone (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)

// 判断是否为iPad

#define kISiPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)

// 系统版本号

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

// 判断是否为iOS8

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

// 根据尺寸判断 是否为4inch

#define is4Inch ([UIScreen mainScreen].bounds.size.height == 568)

文件宏

/************ 获取沙盒Document路径 ************/

#define kDocumentPath [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]

// 获取沙盒temp路径

#define kTempPath NSTemporaryDirectory()

// 获取沙盒Cache路径

#define kCachePath [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]

系统宏

/************ 系统application ************/

#define kApplication [UIApplication sharedApplication]

#define kKeyWindow [UIApplication sharedApplication].keyWindow

#define kAppDelegate [UIApplication sharedApplication].delegate

#define kUserDefaults [NSUserDefaults standardUserDefaults]

#define kNotificationCenter [NSNotificationCenter defaultCenter]

判断宏

/************ 判断 ARC 和 MRC ************/

#if __has_feature(objc_arc)

// ARC

#else

// MRC

#endif

/************ 判断 真机 和 模拟器 ************/

#if TARGET_OS_IPHONE

// iPhone Device

#endif

#if TARGET_IPHONE_SIMULATOR

// iPhone Simulator

#endif

弱引用/强引用

#define kWeakSelf(type) __weak typeof(type) weak##type = type;

#define kStrongSelf(type) __strong typeof(type) type = weak##type;

适配屏幕尺寸宽高比

#define KWidth(width) (IS_SCREEN_4_INCH ? (width * (CGFloat)320 / 375):(IS_SCREEN_47_INCH ? (width):(width *(CGFloat)414 / 375)))

#define KHeight(height) (IS_SCREEN_4_INCH ? (height * (CGFloat)568 / 667):(IS_SCREEN_47_INCH ? (height):(height *(CGFloat)736 / 667)))

IS_SCREEN_4_INCH

判断系统版本代码

// 判断系统版本

#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)

#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)

#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)

#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)

#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)

+ (UIDevice *)currentDevice;

@property(nonatomic,readonly,retain) NSString *name; // e.g. "My iPhone"

@property(nonatomic,readonly,retain) NSString *model; // e.g. @"iPhone", @"iPod touch"

@property(nonatomic,readonly,retain) NSString *localizedModel; // localized version of model

@property(nonatomic,readonly,retain) NSString *systemName; // e.g. @"iOS"

@property(nonatomic,readonly,retain) NSString *systemVersion; // e.g. @"4.0"

@property(nonatomic,readonly) UIDeviceOrientation orientation; // return current device orientation. this will return UIDeviceOrientationUnknown unless device orientation notifications are being generated.

@property(nonatomic,readonly,retain) NSUUID *identifierForVendor NS_AVAILABLE_IOS(6_0); // a UUID that may be used to uniquely identify the device, same across apps from a single vendor.

待修改!!!

网络宏

#define APIURL @"http://xxxxx/"

#define APILogin [APIURL stringByAppendingString:@"Login"]

// 账号相关信息

#define kAppKey @"3637170628"

#define kAppSecret @"b4990ef2e737298552a1c8388fca78c3"

#define kRedirectURI @"https://api.weibo.com/oauth2/default.html"

其他宏

// 方正黑体简体字体定义

#define FONT(size) [UIFont fontWithName:@"FZHTJW--GB1-0" size:size]

//获取一段时间间隔

#define kStartTime CFAbsoluteTime start = CFAbsoluteTimeGetCurrent();

#define kEndTime NSLog(@"Time: %f", CFAbsoluteTimeGetCurrent() - start)

颜色相关知识

24-bit位颜色,每一位占8道,3个颜色通道

白色 #ffffff 最不纯净的颜色

黑色 #000000 是最纯净的颜色

红色 #ff0000

黄色 #ffff00

参考

ios android 宏,iOS常用宏(不断更新)相关推荐

  1. ios,android,塞班,iOS塞班给力 非Android热门手机搜罗

    手机型号:诺基亚N8 参考报价:3000元(水改机)4299元(行货) 推荐理由:诺基亚代表的塞班操作系统由原来的S60更新至今成为了塞班3,系统最出名就是操作方便,但是自从出了Android和苹果之 ...

  2. 官方文档 android ios,Android 和 IOS 办公文件 doc,docx,ppt pdf 文件查看

    更新记录 1.3.0(2021-04-09) 增加了 IOS 端的文件预览查看支持. 1.2.0(2020-07-01) 新增一个 android 系统文件分享的接口. 优化了打开文件时,有部分安卓机 ...

  3. android相比ios,Android相比iOS还差在哪里

    Android相比iOS还差在哪里 2016-04-29 搞机嚒1评 随着科技的发展安卓和IOS的长期演化系统越来越同质化的今天安卓相对于苹果依然很差(至少在一些人眼中)那么为什么会出现这种情况呢?下 ...

  4. iOS日常工作之常用宏定义大全

    前言: 在工作中, 很多小伙伴都会在PCH文件定义一些常用的宏,但是又怕写这些简单的宏浪费时间,又有时候忘记怎么定义了怎么办?本人在工作中也是如此.所以在这里给大家分享一些常用的宏定义,喜欢的小伙伴可 ...

  5. ios android体验,iOS 14终于解决这个痛点,但体验依然不如安卓

    将「雷科技Lite」收藏为我的小程序,不再错过精彩内容 截图几乎是所有智能设备都有的标配功能,手机厂商们还把这样简单的一个功能玩出了各种花样.WWDC过后,苹果推送的iOS 14预览版固件中,添加了一 ...

  6. C语言宏定义、宏函数、内置宏与常用宏

    前言: 在C语言中,变量类型.循环控制.基础语法等与其他高级语言基本无异:而C语言(C++)特有的两把双刃剑指针和宏定义/宏函数使得C语言在底层开发中披荆斩棘.无所不能.这两个概念涉及范围比较广,其分 ...

  7. C语言宏定义(常用宏定义)

    C语言常用宏定义 常用宏定义 数值相关的宏定义 字符相关的宏定义 byte相关的宏定义 bit相关的宏定义 数组与结构体相关的宏定义 对齐的宏定义 常用宏定义 数值相关的宏定义 闰年的判断 ,年份可以 ...

  8. C语言中的宏函数与宏定义

    目录 1.无参宏定义 1.1 无参数宏定义的格式: 1.2 使用说明: 2.带参宏定义 2.1 带参数宏定义的格式: 2.2 使用说明: 3.带参宏定义与函数调用的区别 4.头文件中常用的宏定义 5. ...

  9. iOS - 常用宏定义

    iOS中的常用宏定义 此篇博客为博主转载经典文章,非常感谢原创的优秀资源! 为方便常看和使用,在此我将原文中的宏定义在此以代码片形式展示出来,具体内容如下: #ifndef MacroDefiniti ...

  10. iOS - 常用宏定义和PCH文件知识点整理

    (一)PCH文件操作步骤演示: 第一步:图文所示: 第二步:图文所示: (二)常用宏定义整理: (1)常用Log日志宏(输出日志详细可定位某个类.某个函数.某一行) //=============== ...

最新文章

  1. [导入]源代码版本控制(一)
  2. mysql 分组排序_Python、PowerBI、Excel、MySQL,都能做?搞清楚数据聚合与分箱
  3. SAP MM 没有录入盘点结果的盘点凭证不能执行MI07
  4. python调包侠_拒绝调包侠,不需要高级算法和数据结构技巧
  5. 缓存cache和缓冲区buffer
  6. 【阿里妈妈数据科学系列】第一篇:认识在线实验
  7. checkbox复选框,如何让其勾选时触发一个事件,取消勾选时不触发
  8. 如果$.ajax函数迟迟得不到响应,那么最有可能出错的地方是请求参数写错了
  9. 大数据系统应包含哪些功能模块
  10. 9.打开ZF的错误提示
  11. [Android ] 进度条组件ProgressBar
  12. 防火墙如何打开和关闭某个端口
  13. (一)阿里云创建自己的产品和设备
  14. 百度有道谷歌api集成批量翻译器
  15. 渐进式jpg转换成基线式 jpg
  16. HyperLedger Fabric 查询机制
  17. 主成分分析(PCA)与矩阵奇异值分解(SVD)
  18. 序列的自相关和互相关计算
  19. C语言-报数出圈问题(链表实现)
  20. matlab n阶方阵,用matlab编程设A=(aij)n*n为n阶方阵,求a从1到n? 爱问知识人

热门文章

  1. 带你了解网络的魅力——tcping和ping区别
  2. 放弃大厂高薪的程序员,涌进体制内
  3. matlab给图片滤波,matlab每日学习 图片滤波
  4. windows连接linux
  5. Modelsim的安装教程
  6. matlab自适应遗传算法代码,自适应遗传算法MATLAB代码
  7. 用VB.net编写的Windows服务管理程序(堪称经典)全部源代码
  8. 与代码无关的网络安全
  9. 计算机桌面屏保字幕设置,win7系统屏保设置成字幕保护的操作方法
  10. SQL入门经典思维导图学习