您的位置:首页 > 移动开发 > IOS开发

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

2015-04-13 14:41 99 查看
// 版本判断

#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]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: