title: Load retina (high quality) images programmatically (on buttons)
body: <p>I have a problem that I just haven't been able to figure out. I have an app done that will take a picture from the front and one from the back camera, then merge them together. </p>
  
  <p>The name of the app is <strong>GroupCam</strong></p>
  
  <p>However I have an issue in where my UIButtons will not be loaded as retina images from the start. If i set them as @2x on the interface builder they do appear in high quality but once I reload them programmatically the low versions will appear instead.</p>
  
  <p>This is due to the fact that, after a picture is taken and the screen changes the button images change, but when the user presses the back button the camera icons will look horrible (because the low quality versions are being loaded).</p>
  
  <p>Please check the following pictures:</p>
  
  <p><strong>First Screen:</strong>　Only the upper right button appears distorted because I am checking the value of the camera flash and "loading" the corresponding image programatically.</p>
  
  <p><img src="https://i.stack.imgur.com/8tQfM.jpg" alt="First Screen"></p>
  
  <p><strong>Second Screen:</strong>　The user has moved to another screen and came back to the first one, all buttons were reloaded and they now all look distorted.</p>
  
  <p><img src="https://i.stack.imgur.com/MHD7Y.jpg" alt="Second Screen"></p>
  
  <p>Why is this happening?</p>
  
  <p>Edit:</p>
  
  <p>This is how I load the images.</p>
  
  <pre><code>[self.flashButton setImage:[UIImage imageNamed:@"flashOff"] 
                            forState:UIControlStateNormal];
  </code></pre>
  
  <p>I read somewhere on the internet that doing this will automatically load the most suitable version of the image.</p>
  
  <p>I also tried this but the result is the same:</p>
  
  <pre><code>[self.takeButton setImage:[UIImage imageNamed:@"takePhoto.png"] forState:UIControlStateNormal];
  </code></pre>