IOS开发中常用的 宏命令整理

来源:互联网 发布:2016网络歌曲合集下载 编辑:程序博客网 时间:2024/04/30 03:11
// 版本判断
#define iOS7 SystemVersion >= 7

// 加载图片
#define LoadImage(PATH,TYPE) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:PATH ofType:TYPE]]
// 创建TabBar集合
#define CREATE_TABARITEM(TITLE,PATH,TAG) [[[UITabBarItem alloc] initWithTitle:TITLE image:PATH tag:TAG] autorelease]
// 创建导航视图控制器
#define Create_Navigation(CONTROLLER) [[UINavigationController alloc] initWithRootViewController:CONTROLLER]
// 设置ARBG
#define ARGB(R,G,B,A) [UIColor colorWithRed:R / 255.0 green:G / 255.0 blue:B / 255.0 alpha:A]
// 清空颜色
#define CLEARCOLOR [UIColor clearColor]
// 设置图像为填充色
#define ImageColor(PATH,TYPE) [UIColor colorWithPatternImage:LoadImage(PATH,TYPE)]
// 设置字体大小
#define FONT_WITH_SIZE(SIZE) [UIFont systemFontOfSize:SIZE]
// 创建导航条自定义按钮
#define CUSTOMVIEW(VIEW) [[UIBarButtonItem alloc] initWithCustomView:VIEW]
// 角度旋转
#define DegressToRadian(x) (M_PI * (x) / 180.0)
// AppDelegate
#define ApplicationDelegate    (AppDelegate *)[[UIApplication sharedApplication] delegate]
// MainBundleKey
#define ObjectForBundleKey(Key) [[NSBundle mainBundle] objectForInfoDictionaryKey:Key]
// 屏幕宽度
#define ScreenWidth [UIScreen mainScreen].bounds.size.width
// 屏幕高度
#define ScreenHeight [UIScreen mainScreen].bounds.size.height
// 判断是否为iPhone5
#define iPhone5 ScreenHeight > 480
// 加载文件来自Bundle
#define FileForBundle(PATH, TYPE) [[NSBundle mainBundle] pathForResource:PATH ofType:TYPE]
// 项目主体颜色
#define MainColor [UIColor whiteColor]
// 系统版本
#define SystemVersion [[[UIDevice currentDevice] systemVersion] floatValue]
0 0
原创粉丝点击