title: Xcode 7, asset catalog universal device background image support?
body: <p>I've seen various old posts regarding image sizes, but I can't find anything up-to-date or even know if it's possible with just asset catalog to provide images for all iPad and iPhone screen sizes.?</p>
  
  <p>This is the best post I've found, but in Xcode 7 it doesn't show "Retina 4 2x" or the iPhone 6 / 6+</p>
  
  <p><a href="https://stackoverflow.com/questions/26020979/xcode-6-xcassets-for-universal-image-support?lq=1">Xcode 6 - xcassets for universal image support</a></p>
  
  <p>In xcode 7 there is a universal option, but the three images don't support all the device sizes.</p>
  
  <p>I've seen options where you can provide your own images outside of asset catalog, but I'd really like to use asset catalog.</p>
  
  <p><a href="https://stackoverflow.com/questions/29100590/how-to-use-xcassets-universal-background-images-for-different-iphones-ipads">How to use xcassets/universal background images for different iPhones/iPads?</a></p>
  
  <p>EDIT:
  It looks like I might have to go for the none asset catalog route :(</p>
  
  <p>A)</p>
  
  <p>I'd like to future proof this solution, so it falls back and if needs be, resize the most appropriate image, as-is I'm not sure will happen.</p>
  
  <pre><code>NSNumber *screenWidth = @([UIScreen mainScreen].bounds.size.width);
  NSString *imageName = [NSString stringWithFormat:@"name-%@w", screenWidth];
  UIImage *image = [UIImage imageNamed:imageName];
  </code></pre>
  
  <p>B)</p>
  
  <p>Or maybe this code is better? Although I'm not sure what sizes this relates to, it's also a bit out of date as it doesn't support x3 images ?</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @interface UIImage (DefaultImage)
  
  // uses statusbar orientation
  + (UIImage *)defaultImage;
  
  //uses given orientation
  + (UIImage *)defaultImageForOrientation:(UIInterfaceOrientation)orient;
  
  @end
  </code></pre>
  
  <hr>
  
  <pre><code>@implementation UIImage (DefaultImage)
  
  + (UIImage *)defaultImage {
      return [self defaultImageForOrientation:[[UIApplication sharedApplication] statusBarOrientation]];
  }
  
  + (UIImage  *)defaultImageForOrientation:(UIInterfaceOrientation)orient {
      // choose the correct launch image for orientation, device and scale
      NSMutableString *launchImageName = [[NSMutableString alloc] initWithString:@"Default"];
      BOOL isPad = ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad );
      if ( isPad ) {
          BOOL isLandscape = UIInterfaceOrientationIsLandscape(orient);
          NSString *imageOrientation = (isLandscape) ? @"Landscape" : @"Portrait";
  
          BOOL isRetina = ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] &amp;&amp; [[UIScreen mainScreen] scale] == 2.0);
          NSString *scaleString = (isRetina) ? @"@2x" : @"";
  
          // Default-Landscape~ipad.png
          // Default-Landscape@2x~ipad.png
          // Default-Portrait~ipad.png
          // Default-Portrait@2x~ipad.png
          launchImageName = [NSMutableString stringWithFormat:@"%@-%@%@.png", launchImageName, imageOrientation, scaleString];       
      } else {
          if ( CGRectGetHeight([UIScreen mainScreen].bounds) &gt; 480.f) {
              // Default-568h.png
              launchImageName = [NSMutableString stringWithFormat:@"%@-568h.png", launchImageName];
          } else {
              // Default.png
              // Default@2x.png
              launchImageName = [NSMutableString stringWithFormat:@"%@.png", launchImageName];
          }
      }
      return [UIImage imageNamed:launchImageName];
  }
  
  @end
  </code></pre>
  
  <p>Disclaimer: taken from <a href="https://github.com/Daij-Djan/DDUtils" rel="nofollow noreferrer">https://github.com/Daij-Djan/DDUtils</a></p>
  
  <p>C)</p>
  
  <p>This also looks good, but it's re-sizing and not using actual sharp images and there's no fall back.</p>
  
  <p><a href="https://gist.github.com/kevindelord/fe2e691d06ab745fbb00" rel="nofollow noreferrer">https://gist.github.com/kevindelord/fe2e691d06ab745fbb00</a></p>
  
  <pre><code>NSString *extension = @"";      // iPhone 3GS and earlier
  if (scale == 3.f) {
      extension = @"@3x";         // iPhone 6 Plus
  } else if (scale == 2.f &amp;&amp; h == 568.0f &amp;&amp; w == 320.0f) {
      extension = @"-568h@2x";    // iPhone 5, 5S, 5C
  } else if (scale == 2.f &amp;&amp; h == 667.0f &amp;&amp; w == 375.0f) {
      extension = @"-667h@2x";    // iPhone 6
  } else if (scale == 2.f &amp;&amp; h == 480.0f &amp;&amp; w == 320.0f) {
      extension = @"@2x";         // iPhone 4, 4S
  } else if (scale == 1.f &amp;&amp; h == 1024.0f &amp;&amp; w == 768.0f) {
      extension = @"-512h";       // iPad Mini, iPad 2, iPad 1
  } else if (scale == 2.f &amp;&amp; h == 1024.0f &amp;&amp; w == 768.0f) {
      extension = @"-1024h@2x";   // iPad Mini 3, iPad Mini 2, iPad Air, iPad Air 2
  }
  return extension;
  </code></pre>