编程屏幕截图 [英] Crop Screen shot Programatically

查看:114
本文介绍了编程屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要通过编程方式截取屏幕截图,并通过电子邮件发送。我可以做到这一点,但在这里完整的屏幕截图附加电子邮件,但我想裁剪的屏幕截图发送。
我如何做到这一点请建议我这样做。

I want to take screen shot through programatically 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();


推荐答案

40是从底部裁剪屏幕截图40像素。

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();

这篇关于编程屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆