Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Let's say you have an array of source images:</p> <pre><code>NSArray *sourceImages = ...; // each element of sourceImages is a UIImage </code></pre> <p>Now you want to take the first <code>count</code> images from the array and concatenate them vertically into a new image. Start by figuring out the size of the combined image:</p> <pre><code>CGSize combinedSize = CGSizeMake(0, 0); for (int i = 0; i &lt; count; ++i) { CGSize sourceSize = [sourceImages[i] size]; combinedSize.width = MAX(combinedSize.width, sourceSize.width); combinedSize.height += sourceSize.height; } </code></pre> <p>Next, create a graphics context of that size:</p> <pre><code>UIGraphicsBeginImageContextWithOptions(combinedSize, NO, 0); { </code></pre> <p>Now draw each component image into the graphics context at the appropriate position:</p> <pre><code> CGFloat y = 0; for (int i = 0; i &lt; count; ++i) { UIImage *sourceImage = sourceImages[i]; [sourceImage drawAtPoint:CGPointMake(0, y)]; y += sourceImage.size.height; } </code></pre> <p>Finally, create the combined image from the context and dispose of the context:</p> <pre><code>} UIImage *combinedImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); </code></pre> <p>Read <a href="http://developer.apple.com/library/ios/documentation/2ddrawing/conceptual/drawingprintingios/HandlingImages/Images.html#//apple_ref/doc/uid/TP40010156-CH13-SW1" rel="nofollow"><em>Drawing and Printing Guide for iOS</em> - Drawing and Creating Images</a> for more information.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload