Skip to content

Instantly share code, notes, and snippets.

@coreyfloyd
Created February 13, 2010 20:29
Show Gist options
  • Save coreyfloyd/303661 to your computer and use it in GitHub Desktop.
Save coreyfloyd/303661 to your computer and use it in GitHub Desktop.
UIImage* bottomImage = [UIImage imageNamed:@"bottom.png"];  
UIImage* topImage    = [UIImageNamed:@"top.png"];
UIImageView* imageView = [[UIImageView alloc] initWithImage:bottomImage];
UIImageView* subView   = [[UIImageView alloc] initWithImage:topImage];
subView.alpha = 0.5;  // Customize the opacity of the top image.
[imageView addSubview:subView];
UIGraphicsBeginImageContext(imageView.frame.size);
[imageView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage* blendedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[subView release];
[imageView release];
[self doWhateverIWantWith: blendedImage];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment