In Cocoa NSImage has a lockFocus method, that allows to draw images offscreen and combine them into one.
[img lockFocus];
//...
[img unlockFocus];
On the iPhone, UIImage lacks the lockFocus methods, instead the following:
UIGraphicsBeginImageContext(CGSizeMake(64.0f, 64.0f));
// ...
[img drawAtPoint:CGPointZero];
[view drawRect:CGRectMake(0.0f, 0.0f, 64.0f, 64.0f)];
UIImage *outputImg =
UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();