[英]iPhone: can i save the screen or take screen shot to practicular area of view
屏幕上有一个图像,我必须通过截屏保存该图像。 是否有其他方法仅保存图像的特定区域?
如果有方法,请用一个简单的例子指导我。
如果您需要一种编程方式来实现此目的,则可以使用:
[[NSImage alloc] initWithData:[view dataWithPDFInsideRect:[view bounds]]];
以下代码将使您仅抓取屏幕的一部分,即可适应全屏显示
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();
如果您只想截取屏幕截图,只需同时按下主屏幕和顶部按钮即可,每次您将屏幕快照都放入相册中
尝试同时按下主页和关闭/电源按钮。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.