title: iOS: Using LaunchImage as app background
body: <p>Is this possible without glitches?</p>
  
  <p>My Xcode project has a launch image defined in the assets (aka Images.xcassets) incl. all supported sizes and orientations. Since I want to use the same image as background in my initial view, I add it in the view controller as background:</p>
  
  <pre><code>    view.layer.contents = UIImage(named:"LaunchImage").CGImage;
  </code></pre>
  
  <p>However when the launch screen switches to the initial view there's a noticeable glitch since the background image set in the view stretches. Also when I rotate the device, the image stretches.</p>
  
  <p>The stretching occurring when the device is rotated seems plausible since obviously the other image sizes/orientations in the asset catalog image aren't regarded when set as a background image (my guess).</p>
  
  <p>But the stretching that occurs between launch screen and my initial view seems rather strange since the two should have the same size.</p>
  
  <p>Is there any tried and tested procedure to have the bg image always adapt with aspect ratio in mind when the device orientation changes? And is this even possible wit the (multi-sized) launch image?</p>
  
  <hr>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>One possible method to add a bg image is by placing a <code>UIImageView</code> in the background (behind all other views) and load the image into it. That solution takes care of the device orientation issue and would be OK for me but there is another issue: It loads the wrong image size. If I test it on iPad2 emu it should use the image named <strong>Default~ipad~nostatusbar.png</strong> but if I check the size of the <code>UIImage</code> it is only 320x480 pixels so it obviously used the image named <strong>Default.png</strong>.</p>
  
  <p>And I can only load the launch image by the name defined in the Images.xcassets. If I try to create a UIImage with physical filename (e.g. Default.png) the bg will stay black.</p>
  
  <p>So the question is: How do I get iOS to choose the right image size/orientation from LaunchImage in Images.xcassets?</p>