码迷,mamicode.com
首页 > 移动开发 > 详细

iOS 常用宏定义

时间:2015-03-11 10:57:03      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:ios   开发   设置   模式   效果   

下面是在iOS开发中常用的一些宏定义:

//一般的提示信息
#define mAlertView(title, msg) \
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show];

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

// GCD
#define BACK(block) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block)
#define MAIN(block) dispatch_async(dispatch_get_main_queue(),block)

//----------界面設計相關-------

#define mNavBarHeight         44
#define mTabBarHeight         50
#define mScreenWidth          ([UIScreen mainScreen].bounds.size.width)
#define mScreenHeight         ([UIScreen mainScreen].bounds.size.height)

//----------設備系統相關---------
#define mRetina   ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)
#define mIsiP5    ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136),[[UIScreen mainScreen] currentMode].size) : NO)
#define mIsiP6    ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334),[[UIScreen mainScreen] currentMode].size) : NO)
#define mIsiP6Plus    ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208),[[UIScreen mainScreen] currentMode].size) : NO)

#define mIsPad    (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define mIsiphone (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define mIsIOS7OrLater ([mSystemVersion floatValue] >= 7.0 ? YES : NO)
#define mIsIOS8OrLater ([mSystemVersion floatValue] >= 8.0 ? YES : NO)

#define mSystemVersion   ([[UIDevice currentDevice] systemVersion])
#define mDeviceOpenUDID  ([OpenUDID value])
#define mDeviceModel     ([[UIDevice currentDevice] model])
#define mDeviceName      ([[UIDevice currentDevice] name])
#define mCurrentLanguage ([[NSLocale preferredLanguages] objectAtIndex:0])
#define mAPPVersion      [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]
#define mFirstLaunch     mAPPVersion     //以系統版本來判斷是否第一次啓動,包括升級後啓動
#define mFirstRun        @"firstRun"     //判斷是否第一次運行,升級後啓動不算

iOS 常用宏定义

标签:ios   开发   设置   模式   效果   

原文地址:http://blog.csdn.net/jichunw/article/details/44177917

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!