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:未找到(返回类型默认为 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要
#import
You need to
#import <QuartzCore/QuartzCore.h>