iOS屏幕截图警告

iOS屏幕截图警告,ios,warnings,screenshot,Ios,Warnings,Screenshot,我需要在我的应用程序中截取一些图表 Im使用以下代码: CGRect screenRect = [[UIScreen mainScreen] bounds]; UIGraphicsBeginImageContext(screenRect.size); CGContextRef ctx = UIGraphicsGetCurrentContext(); [[UIColor blackColor] set]; CGContextFillRect(ctx, screenRect); [self.view

我需要在我的应用程序中截取一些图表

Im使用以下代码:

CGRect screenRect = [[UIScreen mainScreen] bounds];
UIGraphicsBeginImageContext(screenRect.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
[[UIColor blackColor] set];
CGContextFillRect(ctx, screenRect);
[self.view.layer renderInContext:ctx];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
但是在
[self.view.layer renderInContext:ctx]中我得到警告
实例方法-renderInContext:notfound(返回类型默认为id)

那么,我错过了什么?要避免此警告并成功拍摄我的屏幕快照


非常感谢

我想,你需要导入QuartzCore框架,并将其添加到项目中。除了WrightCS下面的答案外,你可能还需要查看UIContextBeginImageContextWithOptions,如下所示-你目前拥有的将始终以非视网膜质量渲染。