Codec ░ combine

334Combining Images with UIImage & CGContext – (Offscreen drawing)

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:

// Create new offscreen context with desired size
UIGraphicsBeginImageContext(CGSizeMake(64.0f, 64.0f));
 
// draw img at 0,0 in the context
[img drawAtPoint:CGPointZero];
 
// draw another at 0,0 in the context, maybe with an alpha value
[another drawAtPoint:CGPointZero];
 
// ... and other operations
 
// assign context to UIImage
UIImage *outputImg = UIGraphicsGetImageFromCurrentImageContext();
 
// end context
UIGraphicsEndImageContext();

581Resizing an UIImage 569Layering one UIImage onto of another UIImage 553CAAnimation and the Snapback Problem 347UIImage → pixelData → UIImage Rountrip 338Accessing RGBA Pixel Data

73Concatenating Strings @”string1″ @”string2″ @”stringN”

That’s basically it.

No more
[@"string1" stringByAppendingString:@"string2"];

or
[NSString stringWithFormat:@"string1%@", @"string1"];

just
@"string1" @"string2" @"stringN" -> @"string1string2stringN"

The Objective-C 2.0 Programming Language.pdf, p131

565Stripping Characters from an NSString 564NSData to NSString and vice versa 532OSC to and from the iPhone with VVOSC 484Printing Selectors in NSLog 452Padding with Zeros (or other characters)