Note that there are some explanatory texts on larger screens.

plurals
  1. POUIImage position
    text
    copied!<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/6763678/uiimage-position">UIImage position</a> </p> </blockquote> <p>I'm using the following code to place some images in the UIView:</p> <pre><code>UIImage *image; UIGraphicsBeginImageContext(CGSizeMake(480, 320)); int k=0; int posY=0; for (int i=0; i&lt;[theArray count]; i++) { image=[UIImage imageNamed:[NSString stringWithFormat:@"%@",[theArray objectAtIndex:i]]]; if (k&gt;2) { k=0; posY++; } [image drawAtPoint:CGPointMake(k*64, posY*23)]; k++; } UIImage *combinatedImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); </code></pre> <p>obtaining this result</p> <p><a href="http://cl.ly/8bSP" rel="nofollow noreferrer">http://cl.ly/8bSP</a></p> <p>but i would like to obtain this:</p> <p><a href="http://cl.ly/8c6Q" rel="nofollow noreferrer">http://cl.ly/8c6Q</a></p> <p>i can't figure out, i am so confused. Can somebody help me, please??? thanks!!</p> <p><strong>[SOLVED]</strong></p> <p>This is my final working solution</p> <pre><code>UIGraphicsBeginImageContext(CGSizeMake(480, 320)); int k=0; int posY=0; int d = 0; for (int i=0; i&lt;[theArray count]; i++) { int imagesLeft = MIN(3, [theArray count]-i); image=[UIImage imageNamed:[NSString stringWithFormat:@"%@",[theArray objectAtIndex:i]]]; if (k&gt;2) { k=0; d=(3-imagesLeft)*32; posY++; } [image drawAtPoint:CGPointMake(k*64+d, posY*23)]; k++; NSLog(@"image nr. %i = %i",i,imagesLeft); } UIImage *combinatedImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); </code></pre> <p>Thanks for suggestions!</p>
 

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