iOS 截图警告

发布于 2024-12-02 06:15:36 字数 602 浏览 3 评论 0原文

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

我使用以下代码:

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:未找到(返回类型默认为 id)

那么,我缺少什么?为了避免这个警告并成功拍摄我的屏幕截图?

多谢!

I need to take a screen shot of some charts in my app,

Im using the following code:

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();

but in [self.view.layer renderInContext:ctx]; I get the warning Instance method -renderInContext: not found (return type defaults to id)

So, what Im I missing? to avoid this warning and successfully take my screen shot??

thanks a lot!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

少年亿悲伤 2024-12-09 06:15:36

您需要#import

You need to #import <QuartzCore/QuartzCore.h>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文