Common macro definitions for IOS development

  1. //-------------------Get device size-------------------------  
  2. //NavBar height  
  3. #define NavigationBar_HEIGHT 44  
  4. //Get screen width and height  
  5. #define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)  
  6. #define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)  
  7.   
  8. //-------------------Get device size-------------------------  
  9.   
  10.   
  11. //------------------- print log-------------------------  
  12. //Print log in DEBUG mode, current line  
  13. #ifdef DEBUG  
  14. #   define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);  
  15. #else  
  16. #   define DLog(...)  
  17. #endif  
  18.   
  19.   
  20. //Rewrite NSLog, print the log and the current number of lines in Debug mode  
  21. #if DEBUG  
  22. #define NSLog(FORMAT, ...) fprintf(stderr,"\nfunction:%s line:%d content:%s\n", __FUNCTION__, __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);  
  23. #else  
  24. #define NSLog(FORMAT, ...) nil  
  25. #endif  
  26.   
  27. //Print log in DEBUG mode, current line and pop up a warning  
  28. #ifdef DEBUG  
  29. #   define ULog(fmt, ...)  { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"%s\n [Line %d] ", __PRETTY_FUNCTION__, __LINE__] message:[NSString stringWithFormat:fmt, ##__VA_ARGS__]  delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; [alert show]; }  
  30. #else  
  31. #define ULog (...)  
  32. #endif  
  33. //ios7 system judgment:


    #define IsIOS7 ([[[UIDevice currentDevice] systemVersion] floatValue] >=7.0 ? YES : NO)

    //Determine whether it is Retina screen, whether it is IPhone5, whether it 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)

      

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325405797&siteId=291194637