判断设备类型iPad/iPhone
#define IS_IPAD(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_PHONE(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IOS_VERSION[[UIDevice currentDevice] systemVersion]
#define IOS_VERSION_NUMBER[IOS_VERSION intValue]
#define IS_IOS(number)(IOS_VERSION_NUMBER >= (int)(number))
#define IS_IOS_7YES
#define IS_IOS_8IS_IOS(8)
#define IS_IOS_9IS_IOS(9)
#define iPhone4 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640,960), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640,1136), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750,1334), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhone6Plus ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242,2208), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhone6OrPlus (iPhone6 || iPhone6Plus)
#define WEAKSELF(n)__weak __typeof(self) n = self
#define PHONE_PAD_VALUE(iPhone_value, iPad_value)(IS_PHONE ? (iPhone_value) : (iPad_value))
#define BLKBLOCK(b, ...)if (b) b(__VA_ARGS__)
#define BLK_ARRAY_ADD_OBJ(array, object) if ((object))[array addObject:object]
#define VALIDSTRING(str)((str)?:@"")
#define IS_ZERO(num)(!((num) >0) && !((num) <0))
#define RUN_ONMAINTHREAD_AFTER(second, block) if (block) dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (second) * NSEC_PER_SEC), dispatch_get_main_queue(), block);
#define RUN_ONMAINTHREAD(block) if (block) dispatch_async(dispatch_get_main_queue(), block);
颜色RGB
#define RGBA(R, G, B, A)[UIColor colorWithRed:(R)/255.0fgreen:(G)/255.0fblue:(B)/255.0falpha:(A)]
#define RGB(R, G, B)[UIColor colorWithRed:(R)/255.0fgreen:(G)/255.0fblue:(B)/255.0falpha:1.0f]
iOS开发常用宏定义
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- typeof操作符 是操作符,不是函数,后面可以带(),也可以不带() 返回的结果都是小写字母 函数类型返回fun...