0

I want to take screen shot through programmatically and send with Email. I am able to do this but here full screenshot attached with email but I want to crop the screen shot for sending. How can I do this Please suggest me to do this.

Here is my code for taking screen shot.

UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

1 Answer 1

3

I used this to crop screen shot from bottom here -40 is crop screenshot by 40 pixels from bottom.

UIGraphicsBeginImageContext(self.view.bounds.size);
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(c,-40,0);    // <-- shift everything up by 40px when drawing.
[self.view.layer renderInContext:c];
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.