///是否是iPad
#define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
///设备高度
#define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height
///设备宽度
#define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width
打印
#ifdef DEBUG
#define DLog( s, ... ) NSLog( @"<%p %@:(%d)> %@", self, [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )
#else
#define DLog( s, ... )
#endif
操作系统判断
//判断设备的操做系统是不是ios7
#define IOS7 ([[[UIDevice currentDevice].systemVersion doubleValue] >= 7.0]
判断iPhone X
#define SCREEN_MAX_LENGTH (MAX(SCREEN_WIDTH, SCREEN_HEIGHT))
#define IS_IPHONE_X (SCREEN_MAX_LENGTH == 812.0 ? YES : NO)
//NavBar高度
#define NavigationBar_HEIGHT 44
引用
#define WIDTH(view) view.frame.size.width
#define HEIGHT(view) view.frame.size.height
#define X(view) view.frame.origin.x
#define Y(view) view.frame.origin.y
#define LEFT(view) view.frame.origin.x
#define TOP(view) view.frame.origin.y
#define BOTTOM(view) (view.frame.origin.y + view.frame.size.height)
#define RIGHT(view) (view.frame.origin.x + view.frame.size.width)
#define HFrame(X,Y,W,H) CGRectMake((X),(Y),(W),(H))
RGB色值
#define RGB(r,g,b)[UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:1]
读取本地图片 此方法性能优越于 UIImage imageNamed,它没有存储,适合大量的图片的获取应用,如果需要频繁使用还是用UIImage imageNamed,读取本地图片,取不到Assets.xcasets的图片,由于它不是文件目录
#define LOADIMAGE(file,ext) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle]pathForResource:file ofType:ext]]
字符串和字体
#define FONT(F) [UIFont systemFontOfSize:F]
#define STRINGFORMART(D,F) [NSString stringWithFormat:D,F]
随机色
#define kRandColor [UIColor colorWithRed:arc4random() % 255 / 255.0f green:arc4random() % 255 / 255.0f blue:arc4random() % 255 / 255.0f alpha:1.0f]