OGeek|极客世界-中国程序员成长平台

标题: iOS 截图警告 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 17:20
标题: iOS 截图警告

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

我使用以下代码:

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]; 我得到警告 Instance method -renderInContext: not found (return type defaults to id)

那么,我错过了什么?避免此警告并成功截取我的屏幕截图??

非常感谢!



Best Answer-推荐答案


你需要#import

关于iOS 截图警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7253624/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4