Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you want check it <strong>Programmatically</strong> :</p> <p>For checking <strong>Retina (3.5/4 inch Screen) or Non-Retina</strong> </p> <pre><code>if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { if ([[UIScreen mainScreen] scale] == 2.0) { if([UIScreen mainScreen].bounds.size.height == 568){ // iPhone retina-4 inch } else{ // iPhone retina-3.5 inch } } else { // not retina display } </code></pre> <p><strong>Update:</strong> </p> <p>checking <strong>ios8 or ios 7</strong> </p> <pre><code>NSOperatingSystemVersion ios8_0_0 = (NSOperatingSystemVersion){8, 0, 0}; if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:ios8_0_0]) { // iOS 8 stuff } else { // iOS 7 and below stuff } </code></pre> <p>For checking <strong>All retina iPhone</strong> Programmatically:</p> <pre><code>if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { if ([[UIScreen mainScreen] scale] == 2.0) { if([UIScreen mainScreen].bounds.size.height == 667){ // iPhone retina-4.7 inch(iPhone 6) } else if([UIScreen mainScreen].bounds.size.height == 568){ // iPhone retina-4 inch(iPhone 5 or 5s) } else{ // iPhone retina-3.5 inch(iPhone 4s) } } else if ([[UIScreen mainScreen] scale] == 3.0) { //if you want to detect the iPhone 6+ only if([UIScreen mainScreen].bounds.size.height == 736.0){ //iPhone retina-5.5 inch screen(iPhone 6 plus) } //iPhone retina-5.5 inch screen(iPhone 6 plus) } } </code></pre> <p>Also check this</p> <pre><code>#define IS_IPHONE_5 (IS_IPHONE &amp;&amp; [[UIScreen mainScreen] bounds].size.height == 568.0) #define IS_IPHONE_6 (IS_IPHONE &amp;&amp; [[UIScreen mainScreen] bounds].size.height == 667.0) #define IS_IPHONE_6_PLUS (IS_IPHONE &amp;&amp; [[UIScreen mainScreen] bounds].size.height == 736.0) </code></pre> <p><strong>FOR Swift 3.0</strong></p> <pre><code>if UIDevice().userInterfaceIdiom == .Phone { switch UIScreen.mainScreen().nativeBounds.height { case 480: print("iPhone Classic") case 960: print("iPhone 4 or 4S") case 1136: print("iPhone 5 or 5S or 5C") case 1334: print("iPhone 6 or 6S or 7") case 1920: print("iPhone 6+ or 6S+ or 7+") default: print("unknown") } } </code></pre> <p>You can also extend UIDevice as follow:</p> <pre><code>extension UIDevice { var iPhone: Bool { return UIDevice().userInterfaceIdiom == .Phone } enum ScreenType: String { case iPhone4 case iPhone5 case iPhone6/iPhone7 case iPhone6Plus/iPhone6splus/iPhone7plus case unknown } var screenType: ScreenType { guard iPhone else { return .unknown } switch UIScreen.mainScreen().nativeBounds.height { case 960: return .iPhone4 case 1136: return .iPhone5 case 1334: return .iPhone6/iPhone7 case 1920: return .iPhone6Plus/iPhone6splus/iPhone7plus default: return .unknown } } } </code></pre> <hr> <p>edit/update <strong>Xcode 8.1 • Swift 3.0.1</strong></p> <pre><code>extension UIDevice { var iPhone: Bool { return UIDevice().userInterfaceIdiom == .phone } enum ScreenType: String { case iPhone4 case iPhone5 case iPhone6/iPhone7 case iPhone6Plus/iPhone6splus/iPhone7plus case unknown } var screenType: ScreenType { guard iPhone else { return .unknown } switch UIScreen.main.nativeBounds.height { case 960: return .iPhone4 case 1136: return .iPhone5 case 1334: return .iPhone6/iPhone7 case 1920: return .iPhone6Plus/iPhone6splus/iPhone7plus default: return .unknown } } } </code></pre> <p>may it will help you .</p> <p>Happy coding.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload