判断设备类型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]
网友评论