# iOSGlobal.h **Repository Path**: KevenLi/iOSGlobal.h ## Basic Information - **Project Name**: iOSGlobal.h - **Description**: iOS常用宏定义 - **Primary Language**: Unknown - **License**: GPL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2014-07-07 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README #iOSGlobal.h // 判断是否是iPhone5 #define isPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO) // 是否iPad #define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) /// 是否模拟器 #ifdef TARGET_IPHONE_SIMULATOR #define isSimulator TARGET_IPHONE_SIMULATOR #endif /// 屏幕高度、宽度 #define Screen_height [[UIScreen mainScreen] bounds].size.height #define Screen_width [[UIScreen mainScreen] bounds].size.width #pragma mark - System Version /// 当前系统版本大于等于某版本 #define IOS_SYSTEM_VERSION_EQUAL_OR_ABOVE(v) (([[[UIDevice currentDevice] systemVersion] floatValue] >= (v))? (YES):(NO)) /// 当前系统版本小于等于某版本 #define IOS_SYSTEM_VERSION_EQUAL_OR_BELOW(v) (([[[UIDevice currentDevice] systemVersion] floatValue] <= (v))? (YES):(NO)) /// 当前系统版本 #define IOS_SYSTEM_VERSION [[[UIDevice currentDevice] systemVersion] floatValue] #define iOS7 (IOS_SYSTEM_VERSION >= 7.0) /// 系统语言 #define IOS_SYSTEM_Language ([[NSLocale preferredLanguages] objectAtIndex:0]) /// 当前应用版本号 #define AppVersion [[NSBundle mainBundle] infoDictionary][@"CFBundleVersion"] #pragma mark - common path /// 常用文件路径 #define PathForDocument NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0] #define PathForLibrary NSSearchPathForDirectoriesInDomains (NSLibraryDirectory, NSUserDomainMask, YES)[0] #define PathForCaches NSSearchPathForDirectoriesInDomains (NSCachesDirectory, NSUserDomainMask, YES)[0] #pragma mark - shared tool #define SharedUserDefault [NSUserDefaults standardUserDefaults] #define SharedNotificationCenter [NSNotificationCenter defaultCenter] #define SharedFileManager [NSFileManager defaultManager] #define SharedApplicationDelegate [[UIApplication sharedApplication] delegate] #pragma mark - image && color /// 加载图片 #define UIImageLoad(name, type) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle]pathForResource:name ofType:type]] #define UIImageNamed( name ) [UIImage imageNamed: name] /// 颜色 #define UIColorWithRGBHex(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0] #define UIColorWithRGBA(r, g, b, a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a] #define UIColorWithRGB(r, g, b) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:1.0] #pragma mark - GCD #define GCDGlobal( b ) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), b) #define GCDMain( b ) dispatch_async(dispatch_get_main_queue(), b)