Skip to content

Instantly share code, notes, and snippets.

@barbosa
Created September 29, 2013 13:35
Show Gist options
  • Select an option

  • Save barbosa/6752577 to your computer and use it in GitHub Desktop.

Select an option

Save barbosa/6752577 to your computer and use it in GitHub Desktop.

Revisions

  1. barbosa created this gist Sep 29, 2013.
    16 changes: 16 additions & 0 deletions IOSMacros
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    #ifndef IOSVersionMacros_h
    #define IOSVersionMacros_h

    #define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    #define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    #define IS_IPHONE_5 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 568.0f)
    #define IS_IPHONE_4 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 480.0f)
    #define IS_RETINA ([[UIScreen mainScreen] scale] == 2.0f)

    #define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
    #define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
    #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
    #define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
    #define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)

    #endif