IOS development macro definition
IOS development macro definition
In iOS development, you often need to obtain the screen width and height, set the color for the view, and set the image for imgagView. We can define some macros and use them at any time to facilitate development.
# Ifndef FingerTips_Macro_Config_h # define FingerTips_Macro_Config_h // obtain the screen width and height # define SCREEN_WIDTH ([UIScreen mainScreen]. bounds. size. width) # define SCREEN_HEIGHT ([UIScreen mainScreen]. bounds. size. height) // print logs in DEBUG mode. The current line # ifdef DEBUG # define NSLog (format ,...) do {\ fprintf (stderr, "<% s: % d> % s \ n", \ [[[NSString stringwithuf8string :__ FILE _] lastPathComponent] UTF8String], \__ LINE __, _ func __);\ (NSLog) (format), ##__ VA_ARGS _); \ fprintf (stderr, "------- \ n"); \} while (0) # else # define NSLog (...) # endif // determine whether the Retina screen, device % fhone 5, and iPad # define isRetina ([UIScreen instancesRespondToSelector: @ selector (currentMode)]? CGSizeEqualToSize (CGSizeMake (640,960), [[UIScreen mainScreen] currentMode]. size): NO) # define iPhone5 ([UIScreen instancesRespondToSelector: @ selector (currentMode)]? CGSizeEqualToSize (CGSizeMake (640,113 6), [[UIScreen mainScreen] currentMode]. size): NO) # define isPad (UI_USER_INTERFACE_IDIOM () = UIUserInterfaceIdiomPad) // obtain the system version # define IOS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue] # define CurrentSystemVersion [[UIDevice currentDevice] systemVersion] // determine whether it is a real machine or a simulator # if TARGET_ OS _IPHONE/ /iPhone Device # endif # if TARGET_IPHONE_SIMULATOR // iPhone Simul Ator # endif // check the system version # define system_version_to _to (v) ([[UIDevice currentDevice] systemVersion] compare: v options: NSNumericSearch] = NSOrderedSame) # define Merge (v) ([[UIDevice currentDevice] systemVersion] compare: v options: NSNumericSearch] = NSOrderedDescending) # define Merge (v) ([[UIDevice currentDevice] systemVersion] compare: v options: NSNumericSearch]! = NSOrderedAscending) # define SYSTEM_VERSION_LESS_THAN (v) ([[UIDevice currentDevice] systemVersion] compare: v options: NSNumericSearch] = NSOrderedAscending) # define sequence (v) ([[[UIDevice currentDevice] systemVersion] compare: v options: NSNumericSearch]! = NSOrderedDescending) // read the local image # define LOADIMAGE (file, ext) [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource: file ofType: ext] // define the UIImage object # define IMAGE (imageName) [UIImage imageNamed: [NSString stringWithFormat: @ "% @", imageName] // rgb color conversion (hexadecimal> 10 hexadecimal) # define UIColorFromRGB (rgbValue) [UIColor colorWithRed :( (float) (rgbValue & 0xFF0000)> 16)/255.0 green :( (float) (rgbValue & 0xFF 00)> 8)/255.0 blue :( (float) (rgbValue & 0xFF)/255.0 alpha: 1.0] // obtain RGB color # define RGBA (r, g, b, a) [UIColor colorWithRed: r/255.0f green: g/255.0f blue: B/255.0f alpha: a] # define RGB (r, g, B) RGBA (r, g, B, 1.0f) // obtain the screen size # define kDeviceWidth [UIScreen mainScreen]. bounds. size. width # define KDeviceHeight [UIScreen mainScreen]. bounds. size. height # define IS_IOS7 ([[[UIDevice currentDevice] systemVersion] floatValu E] >=7.0 )? (YES) :( NO) # define IS_IOS6 ([[UIDevice currentDevice] systemVersion] floatValue]> = 6.0 )? (YES) :( NO) # define IS_4INCH ([UIScreen instancesRespondToSelector: @ selector (currentMode)]? CGSizeEqualToSize (CGSizeMake (640,113 6), [[UIScreen mainScreen] currentMode]. size): NO) // release the memory # define RELEASE_SAFE (_ Pointer) do {[_ Pointer release], _ Pointer = nil;} while (0) # endif