Quote:
Originally Posted by rwenderlich
You can draw the images to a "virtual" graphics context and then convert that graphics context into an image.
For example you can write code that looks something like this:
Code:
UIGraphicsBeginImageContext(contextRect);
[frame drawInRect:frameRect];
[image drawInRect:imageRect];
UIImage *finalImage = UIGraphicsGetImageFromCurrentImageContext();
|
I tried this-
Code:
CGRect contextRect = CGRectMake(-100, -100, 226, 155);
UIGraphicsBeginImageContext(contextRect.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
But the resulting image is starting from origin (0,0) of screen whether I'm giving anything for x and y. But height and width are working as defined. Any solution for this?
thanx for you reply. It really worked for me