我正在使用ScratchPadView for iphone应用程序,当我在暂存器上截屏时,我写了一些东西,但它没有显示内容

时间:2013-10-25 11:57:44

标签: ios iphone objective-c screenshot

 UIGraphicsBeginImageContext(self.bounds.size );
 [self.layer renderInContext:UIGraphicsGetCurrentContext()];
 UIImage *currentScreen = UIGraphicsGetImageFromCurrentImageContext();
 UIGraphicsEndImageContext();

这里无法获得更新的暂存器在屏幕截图上完成的截图,但它没有显示在我的屏幕截图中 ![Scratchpad截图] [1]

1 个答案:

答案 0 :(得分:0)

如果您考虑截取UIView or UIImageView

的屏幕截图,请尝试这样的操作
 UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, YES, 1.0);// Add your view / ScratchPadView whichever you want to take Snap
    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];

    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    [[UIColor redColor] set];
    NSData *imgData =  UIImageJPEGRepresentation(image, 1.0);
    UIGraphicsEndImageContext();