title: How to use xcassets/universal background images for different iPhones/iPads?
body: <p>I would like to display a different background for each different device (i.e. iPhone 4S, iPhone 5, iPhone6, iPhone 6Plus etc.). I am not talking about launch images but app's backgrounds that will be displayed while using the app.</p>
  <p>I have added the following code in my ViewController:</p>
  <pre><code>var bgImage     = UIImage(named: &quot;main_bg&quot;);
  var imageView   = UIImageView(frame: self.view.bounds);
  imageView.image = bgImage
  self.view.addSubview(imageView)
  self.view.sendSubviewToBack(imageView)
  </code></pre>
  <p>And I am ready to add the assets into the Images.xcassets catalog.</p>
  <p>This is what I see when I create a new &quot;Image set&quot;</p>
  <p><img src="https://i.stack.imgur.com/i1DvB.png" alt="enter image description here" /></p>
  <p>Therefore, I am trying to match the assets with each different device.</p>
  <p>Thanks to this question: <a href="https://stackoverflow.com/a/26191308/4063626">universal image support</a> I now know that these devices will access the following images:</p>
  <blockquote>
  <p>iPhone 3 -&gt; 1x (image size: 320x480px)</p>
  <p>iPhone 4/4S/6 -&gt; 2x (image size: 640x960px)</p>
  <p>iPhone 5/5c/5s/iPod Touch -&gt; Retina 4 2x (image size: 640x1336)</p>
  <p>iPhone 6 Plus -&gt; 3x (image size: 1242 x 2208)</p>
  </blockquote>
  <p>My question is, how can iPhones 4/4s and 6 access the same image if, clearly, it's not in the right size for both devices?</p>
  <p>Thank you</p>