-(void)generateImageToPhotoAlbum{ NSLog(@"save image to photo album."); UIGraphicsBeginImageContext(CGSizeMake(1024, 768)); [drawImage.image drawInRect:self.frame]; UIImage *foregroundImage=[UIImage imageWithCGImage:(CGImageRef)foregroundLayer.contents]; [foregroundImage drawInRect:self.frame blendMode:kCGBlendModeNormal alpha:1.0]; UIImage *newImage=UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); UIImageWriteToSavedPhotosAlbum(newImage, nil, nil, nil); }