我正在实现iphone应用程序,我想在其中实现以下功能。 当用户在iphone屏幕上触摸,然后用户快照将产生屏幕的触摸区域并保存到照片库。如何通过编程获得屏幕上触摸部分的快照?
我已经完成了谷歌搜索,但没有成功。
请帮我做这个查询。
在此先感谢
我正在实现iphone应用程序,我想在其中实现以下功能。 当用户在iphone屏幕上触摸,然后用户快照将产生屏幕的触摸区域并保存到照片库。如何通过编程获得屏幕上触摸部分的快照?
我已经完成了谷歌搜索,但没有成功。
请帮我做这个查询。
在此先感谢
如果您正在查找示例代码来控制相机。这里是一个bare bones Camera application that takes picture and saves it to library
检查出这个方法,将触及的视图传递给这个方法,会发送你的图像&保存到库。
- (UIImage*) giveScreentshotsOfView:(UIView*) view
{
if (view == nil)
return nil;
UIGraphicsBeginImageContext(view.bounds.size);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
+ (UIImage *) captureView:(UIView *)view
{
CGRect screenRect = [[UIScreen mainScreen] bounds];
UIGraphicsBeginImageContext(screenRect.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
[[UIColor blackColor] set];
CGContextFillRect(ctx, screenRect);
[view.layer renderInContext:ctx];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
//save the image to photo album
UIImageWriteToSavedPhotosAlbum(newImage, nil, nil , nil);
}
为什么推倒重来,同时按下'家庭和Sleep'按钮的功能在默认情况下拍摄的画面并将其保存到图片库 – 2012-01-11 05:19:07
不,不是这样的...假设我已经打开了我的应用程序,并且亲吻了我的屏幕,然后我的嘴唇将在屏幕上生成并保存到相册中。像那样 – JohnWhite 2012-01-11 05:27:44