简体   繁体   English

iPhone:我可以保存屏幕还是将屏幕截图拍摄到特定的视野

[英]iPhone: can i save the screen or take screen shot to practicular area of view

On my screen there is an image and I have to save this image by taking a screenshot. 屏幕上有一个图像,我必须通过截屏保存该图像。 Is there any other way of saving a particular area of the image only? 是否有其他方法仅保存图像的特定区域?

If there is a method, please guide me with a simple example. 如果有方法,请用一个简单的例子指导我。

如果您需要一种编程方式来实现此目的,则可以使用:

[[NSImage alloc] initWithData:[view dataWithPDFInsideRect:[view bounds]]];

The following code will allow you to grab just a section of the screen, you could adapt for full screen 以下代码将使您仅抓取屏幕的一部分,即可适应全屏显示

    CGRect screenRect = CGRectMake(0, 0, 200, 200);
UIGraphicsBeginImageContext(screenRect.size);

CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextFillRect(ctx, screenRect);

[self.view.layer renderInContext:ctx];

UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();

    //if you want to save this image to the photo album uncomment the next line
//UIImageWriteToSavedPhotosAlbum(newImage, nil, nil, nil);
UIGraphicsEndImageContext();

If you simply want to get a screenshot though just press the home and top button together which will put a screenshot in the photo album each time you do it 如果您只想截取屏幕截图,只需同时按下主屏幕和顶部按钮即可,每次您将屏幕快照都放入相册中

尝试同时按下主页和关闭/电源按钮。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM