iOS开发中的常用宏定义
在iOS开发的过程中合理的使用宏定义能够极大提高编码的速度,下面是一些常用的宏定义,部分内容来自互联网
Log
// 调试状态, 打开LOG功能
#ifdef DEBUG
#define GLLog(...) NSLog(__VA_ARGS__)
#define GLLogMethod NSLog(@"%s", __func__)
#else
// 发布状态, 关闭LOG功能
#define GLLog(...)
#define GLLogMethod
#endif
颜色
#define RGB(r,g,b) [UIColor colorWithRed:r/255. green:g/255. blue:b/255. alpha:1.]
#define RGBA(r,g,b,a) [UIColor colorWithRed:r/255. green:g/255. blue:b/255. alpha:a/100.]
//16进制的颜色
#define RGBHex(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 MainColor RGB(107,185,103)
//主背景色
#define MainBgColor RGB(238,240,243)
屏幕的长度和宽度
#define UIHeight [[UIScreen mainScreen] bounds].size.height
#define UIWidth [[UIScreen mainScreen] bounds].size.width
字体font
#define kFont(x) [UIFont systemFontOfSize:x]
#define kBoldFont(x) [UIFont boldSystemFontOfSize:x]
#define MainFont14 [UIFont systemFontOfSize:14]
#define MainFont15 [UIFont systemFontOfSize:15]
#define MainFont12 [UIFont systemFontOfSize:12]
app名字及版本号
//app名字
#define AppName [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]
//app版本号
#define AppVersion [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString*)kCFBundleVersionKey]
尺寸适配
#define Match(x) (x * UIWidth / 320)
其他
//通知中心
#define GLNotifyCenter [NSNotificationCenter defaultCenter]
//main bundle加载xib文件
#define MainBundle(xx) [[[NSBundle mainBundle] loadNibNamed:xx owner:self options:nil] lastObject]
//个人设置中心
#define GLUserCenter [NSUserDefaults standardUserDefaults]
//weakSelf
#define WS(weakSelf) __weak __typeof(&*self)weakSelf = self;
iOS开发中的常用宏定义的更多相关文章
- iOS 日常工作之常用宏定义大全
转自:http://www.jianshu.com/p/213b3b96cafe 前言: 在工作中, 很多小伙伴都会在PCH文件定义一些常用的宏,但是又怕写这些简单的宏浪费时间,又有时候忘记怎么定义了 ...
- iOS日常工作之常用宏定义大全
前言: 在工作中, 很多小伙伴都会在PCH文件定义一些常用的宏,但是又怕写这些简单的宏浪费时间,又有时候忘记怎么定义了怎么办?本人在工作中也是如此.所以在这里给大家分享一些常用的宏定义,喜欢的小伙伴可 ...
- IOS开发中Xcode常用插件安装与管理(转)
XCode中插件管理工具:Alcatraz 转自http://www.cocoachina.com/industry/20140506/8325.html 苹果现在的成绩得益于其始终如一的坚持. ...
- iOS开发中数组常用的五种遍历方式
随着iOS的不断发展,apple也不断推出性能更高的数组遍历方式,下面将对熟悉的五种遍历方式进行列举. 首先定义一个数组,并获取数组长度 NSArray *array=@[",]; NSIn ...
- iOS开发中一些常用的方法
1.压缩图片 #pragma mark 处理图片 - (void)useImage:(UIImage *)image { NSLog(@"with-----%f heught-----%f& ...
- ios开发中一些常用API总结
转载于:http://www.cnblogs.com/zhucunliang/archive/2013/11/09/3416039.html //1.init初始化 NSString * str1 = ...
- iOS开发中断言的使用—NSAssert()
原文链接:http://blog.csdn.net/univcore/article/details/16859263 断言(assertion)是指在开发期间使用的.让程序在运行时进行自检的代码(通 ...
- iOS开发中常用的数学函数
iOS开发中常用的数学函数 /*---- 常用数学公式 ----*/ //指数运算 3^2 3^3 NSLog(,)); //result 9 NSLog(,)); //result 27 //开平方 ...
- iOS - 常用宏定义和PCH文件知识点整理
(一)PCH文件操作步骤演示: 第一步:图文所示: 第二步:图文所示: (二)常用宏定义整理: (1)常用Log日志宏(输出日志详细可定位某个类.某个函数.某一行) //=============== ...
随机推荐
- Arbitrage
Description Arbitrage is the use of discrepancies in currency exchange rates to transform one unit o ...
- Replicate String in C#
My original posting on string repetition caused a couple responses, and is currently among the Top P ...
- ZOJ 3469 Food Delivery
题目大意: 有n个人,住在一条直线上.第i个人的坐标是Xi,街上有个外卖餐馆的位置是X,现在餐厅工作人员要给街上的每个人送饭,送完之后再回到餐厅,送饭人的速度是V,每个人有个不满意值,当这个人送餐时间 ...
- 用SD卡下载uboot、linux内核和文件系统
1. 移植mtd-utils: a) 下载utd-utils 下载地址为ftp://ftp.infradead.org/pub/mtd-utils/b) 交叉编译mtd-utilsi 修改Make ...
- 浅谈JavaScript函数
JavaScript作为一种基于对象(非严格面向对象)的语言,函数在JS中的地位非同一般:用函数声明类和对象.甚至函数本身也是对象. 一.函数的三种声明方式辨析. 1.function命令 funct ...
- 《傲慢与偏见》(Pride and Prejudice)
<傲慢与偏见>(Pride and Prejudice)改编自英国作家简·奥斯汀的同名小说,1940年上映.讲述了19世纪初期英国的一个普通的中产家庭中五姐妹的爱情与择偶故事.片中因为男主 ...
- redis linux 基本命令
找到一个哥们 写的都是一步步打基础的学习东西 不光是知识也是学习方式 都值得学习.. reids 传送们-->> http://xuelianbobo.iteye.com/category ...
- Android中的RelativeLayout
安卓布局之一,RelativeLayout.又称之为相对布局.对于一个界面每个人都有不同的实现.我比较喜欢使用RelativeLayou.原因是,相对布局不会出现过多的嵌套,在现在硬件不断发展的今天, ...
- 2016最新cocoapods版本更新,以及多个版本的问题
先删除之前的pod 在终端中执行下面命令. 删除目录下的podrm -rf /usr/local/bin/pod 执行gem list | grep cocoapods 查看所有与cocoapods相 ...
- 使用IndexReader.repen提高搜索速度
1,使用indexreader创建indexsearcher. 2,indexsearcher在使用完了以后不要关闭. 3.使用indexreader.isCurrent()判断索引是否被indexw ...