问题
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:
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();
来源:https://stackoverflow.com/questions/7388047/crop-screen-shot-programmatically