简体   繁体   English

如何通过编码,iPhone将应用程序中的屏幕截图缩小到小帧

[英]How to take screen shot in the app to a small frame by coding,iphone

i want to have a screen shot with in the app and then use that image in the next view. 我想在应用程序中进行屏幕截图,然后在下一个视图中使用该图像。 Is there is a way so we can take screen shot of a view in the app and then use that image. 有没有办法让我们可以在应用程序中拍摄视图的屏幕快照,然后使用该图像。

Many thanks in advance 提前谢谢了

gagan joshi 加根乔希

try this one 试试这个

#import <QuartzCore/QuartzCore.h>
@property (retain, nonatomic) IBOutlet UIImageView *imageView;

-(UIImage*)getShot
{
    UIGraphicsBeginImageContext(CGSizeMake(320, 460));
    [imageView.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return viewImage;
}

hope this will help you out for iphone and ipad 希望这会帮助您使用iPhone和iPad

capture screen shot of iphone app 捕获iPhone应用程序的屏幕截图

#import <QuartzCore/QuartzCore.h>
    -(UIImage*)captureImage
    {

        UIGraphicsBeginImageContext(CGSizeMake(320, 460));
        [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
        UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        return viewImage;
    }

Easy to do (assuming self is an UIViewController ): 容易做到(假设self是UIViewController ):

#import < QuartzCore/QuartzCore.h >

...

UIGraphicsBeginImageContext(self.view.bounds.size);

[self.view.window.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage* screenshot = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

Now you have the screenshot in the variable screenshot and can put it into an UIImageView. 现在,您可以将屏幕快照包含在可变屏幕快照中 ,并将其放入UIImageView中。

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

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