Common macro definitions for iOS development
iOS development often need to get screen width height, set color for view, set picture for Imgagview, etc., we can define some macros, can be used at any time, easy to develop
<span style= "FONT-SIZE:18PX;" > #ifndef fingertips_macro_config_h#define fingertips_macro_config_h//get screen width, height # define screen_width ([UIScreen Mainscreen].bounds.size.width) #define Screen_height ([UIScreen mainscreen].bounds.size.height)//DEBUG mode print log, current line # ifdef debug#define NSLog (format, ...) do {fprintf (stderr, "&L t;%s:%d>%s\n ", [[[NSString stringwithutf8string:__file__] Lastpathcomponen T] utf8string], __line__, __func__); (NSLOG) (format), # #__VA_ARGS__); fprintf (stderr, "-------\ n"); } while (0) #else # define NSLOG (...) #endif//Determine if the retina screen, whether the device is%fhone 5, is 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, 1136), [[UIScreen Mainscreen] currentmode].size): NO) #define ISPAD (Ui_user_ Interface_idiom () = = Uiuserinterfaceidiompad)//Get System version # define ios_version [[[Uidevice Currentdevice] systemversion] Floatvalue] #define Currentsystemversion [[Uidevice Currentdevice] systemversion]//to determine whether it is a real machine or a simulator # if target_os_iphone// IPhone device#endif#if target_iphone_simulator//iphone simulator#endif//Check System version # define SYSTEM_VERSION_EQUAL_TO (v) ([[[Uidevice Currentdevice] systemversion] compare:v options:nsnumericsearch] = = nsorderedsame) #define SYSTEM_VERS Ion_greater_than (v) ([[[Uidevice Currentdevice] systemversion] compare:v options:nsnumericsearch] = = NSOrdere ddescending) #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO (v) ([[[[Uidevice Currentdevice] systemversion] Compare:v Options:nsnumericsearch]! = nsorderedascending) #define System_version_less_than (v) ([[[U]IDevice Currentdevice] systemversion] compare:v options:nsnumericsearch] = = nsorderedascending) #define SYSTEM_VERSION _less_than_or_equal_to (v) ([[[Uidevice Currentdevice] systemversion] compare:v options:nsnumericsearch]! = NSOrderedD escending)//read local picture # define LoadImage (File,ext) [UIImage imagewithcontentsoffile:[[nsbundle Mainbundle] Pathforresource:file oftype:ext]]//definition UIImage Object # define IMAGE (ImageName) [UIImage imagenamed:[nsstring stringwithformat:@ "%@", imagename]]//RGB color conversion (16 binary->10) #define UICOLORFROMRGB (rgbvalue) [Uicolor colorwithred :((float) ((Rgbvalue & 0xFF0000) >>)/255.0 Green: ((float) ((Rgbvalue & 0xff00) >> 8))/255.0 Blue: ( (float) (Rgbvalue & 0xFF)) /255.0 alpha:1.0]//get 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)//Get screen size # define Kdevicewidth [UIScreen mainscreen].bounds.size.width#define kdeviceheight [UIScreen mainscreen].bounds.size.height#define Is_ios7 ([[[[Uidevice Currentdevice] systemversion] floatvalue] >= 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, 1136), [[UIScreen Mainscreen] currentmode].size): NO)//Release memory # define RELEASE_SAFE (_ Pointer) Do{[_pointer release],_pointer = nil;} while (0) #endif </span>
Common macro definitions for iOS development