Advertisement
Guest User

Untitled

a guest
Nov 26th, 2015
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. // Device Info & Version Check
  2. #define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
  3. #define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
  4. #define IS_RETINA ([[UIScreen mainScreen] scale] >= 2.0)
  5.  
  6. #define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
  7. #define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
  8. #define SCREEN_MAX_LENGTH (MAX(SCREEN_WIDTH, SCREEN_HEIGHT))
  9. #define SCREEN_MIN_LENGTH (MIN(SCREEN_WIDTH, SCREEN_HEIGHT))
  10.  
  11. #define IS_IPHONE_4_OR_LESS (IS_IPHONE && SCREEN_MAX_LENGTH < 568.0)
  12. #define IS_IPHONE_5 (IS_IPHONE && SCREEN_MAX_LENGTH == 568.0)
  13. #define IS_IPHONE_6 (IS_IPHONE && SCREEN_MAX_LENGTH == 667.0)
  14. #define IS_IPHONE_6P (IS_IPHONE && SCREEN_MAX_LENGTH == 736.0)
  15.  
  16. #define IS_MultiTaskingSupported ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)] && [[UIDevice currentDevice] isMultitaskingSupported])
  17.  
  18. #define IS_IPHONE5 (([[UIScreen mainScreen] bounds].size.height-568)?NO:YES)
  19. #define IS_OS_5_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0)
  20. #define IS_OS_6_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 6.0)
  21. #define IS_OS_7_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
  22. #define IS_OS_8_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
  23.  
  24. // Timer Invalidation
  25. #define m_invalidateTimer(t) [t invalidate]; t = nil;
  26.  
  27. // Threading
  28. #define m_runOnMainThread if (![NSThread isMainThread]) { dispatch_sync(dispatch_get_main_queue(), ^{ [self performSelector:_cmd]; }); return; };
  29.  
  30. // Colors
  31. #define m_rgba(r,g,b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]
  32. #define m_rgb(r,g,b) UA_rgba(r, g, b, 1.0f)
  33.  
  34. // Debugging / Logging
  35. #ifdef DEBUG
  36. //#define DLog( s, ... ) NSLog( @"%@ %s [%d] \t%@", [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __func__, __LINE__ ,[NSString stringWithFormat:(s), ##__VA_ARGS__])
  37. //#define DLog( s, ... ) NSLog( @"%@ [%d] \t%@", [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__ ,[NSString stringWithFormat:(s), ##__VA_ARGS__])
  38. #define DLog( s, ... ) NSLog( @"%s [%d] \t%@", __func__, __LINE__ ,[NSString stringWithFormat:(s), ##__VA_ARGS__] )
  39. #else
  40. #define DLog( s, ... )
  41. #endif
  42.  
  43. #define DLogBounds(view) DLog(@"%@ bounds: %@", view, NSStringFromRect([view bounds]))
  44. #define DLogFrame(view) DLog(@"%@ frame: %@", view, NSStringFromRect([view frame]))
  45.  
  46. // Others
  47. #define NSStringFromBool(b) (b ? @"YES" : @"NO")
  48. #define m_SHOW_VIEW_BORDERS YES
  49. #define m_ShowDebugBorderForViewWithColor(view, color) if (UA_SHOW_VIEW_BORDERS) { view.layer.borderColor = color.CGColor; view.layer.borderWidth = 1.0; }
  50. #define m_showDebugBorderForView(view) UA_showDebugBorderForViewColor(view, [UIColor colorWithWhite:0.0 alpha:0.25])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement