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日志宏(输出日志详细可定位某个类.某个函数.某一行) //=============== ...
随机推荐
- DOMContentLoaded vs onload
http://ie.microsoft.com/testdrive/HTML5/DOMContentLoaded/Default.html The DOMContentLoaded event fir ...
- Play on Words
poj1386:http://poj.org/problem?id=1386 题意:给你n个单词,问你是否能够通过调整单词的顺序存在这样的一个序列,使得 每个单词的首字母是前一个单词的尾字母. 题解: ...
- hdu 5139 Formula
http://acm.hdu.edu.cn/showproblem.php?pid=5139 思路:这道题要先找规律,f(n)=n!*(n-1)!*(n-2)!.....1!; 不能直接打表,而是离 ...
- Maven实战七
转载:http://www.iteye.com/topic/973166 前言 Maven,发音是[`meivin],"专家"的意思.它是一个很好的项目管理工具,很早就进入了我的必 ...
- bzoj1430
这道题只是给bzoj1005做一个铺垫这里介绍了一个叫prufer编码的东西,就是给定一棵带标号的无根树,找出编号最小的叶子节点,写下与它相邻的节点的编号,然后删掉这个叶子节点.反复执行这个操作直到只 ...
- 网络流(最大独立点集):POJ 1466 Girls and Boys
Girls and Boys Time Limit: 5000ms Memory Limit: 10000KB This problem will be judged on PKU. Original ...
- HDOJ(HDU) 2123 An easy problem(简单题...)
Problem Description In this problem you need to make a multiply table of N * N ,just like the sample ...
- 高效算法——E - 贪心-- 区间覆盖
E - 贪心-- 区间覆盖 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=85904#problem/E 解题思路: 贪心思想, ...
- [工具] Numpy
虽说功能强大,要什么基本都有,但感觉它提供的功能还不如Matlab好记呢...Anyway,首先import numpy as np 1. 操作基本单元,矩阵 np.array(list) / np. ...
- 将对象格式的style转换为字符串格式
var style = { position:'absolute', background:'red', width:'2px', height:'2px', color:'#fff', top:x, ...