title: Combining two transparent UIImages?
body: <p>I am trying to combine two transparent UIImages using the following code:</p>
  
  <pre><code>UIImage* image1;
  UIImage* image2;
  
  UIGraphicsBeginImageContext( image1.size );
  
  [ image1 drawInRect: CGRectMake( 0, 0, image1.size.width, image1.size.height ) ];
  [ image2 drawInRect: CGRectMake( 0, 0, image2.size.width, image2.size.height ) ];
  
  UIImage* combinedImage = UIGraphicsGetImageFromCurrentImageContext();
  
  UIGraphicsEndImageContext();
  </code></pre>
  
  <p>The alpha is combined correctly, but the color is not preserved.  Because the CGContext initially has a black color (even though having 0 alpha) the resulting UIImage shifts towards black wherever image1 or image2 is transparent.  How can this be resolved?  I experimented with different blend modes without success.</p>