joh*_*ers 1 cocoa-touch core-animation objective-c compiler-warnings ios
我有这个代码,它正如所期望的那样工作:
UIGraphicsBeginImageContext(self.bounds.size);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage* image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud)
但是,对于这一行:
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
Run Code Online (Sandbox Code Playgroud)
我收到警告(不是错误):
找不到'-renderInContext'方法.
如果实际上该方法有效,我怎么能得到这个警告呢?如果我只是简单地注释掉这一行,我的代码就会失败; 很明显,这条线,以及方法,实际上是有效的.
您需要为CALayer
- 的头文件添加引用#import <QuartzCore/QuartzCore.h>
.您可能还需要将其添加QuartzCore.framework
到项目中.