iOS ARC,接收器类型'CALayer'作为实例消息是前向声明

Seb*_*Seb 3 iphone uiview automatic-ref-counting

你好,

当我插入这个:

UIGraphicsBeginImageContext(imageView.bounds.size);
    [imageView.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud)

我在第2行收到此错误:

接收器类型'CALayer'例如消息是前向声明

我知道它与ARC有关,但还有什么选择呢?

das*_*ght 14

您需要导入<QuartzCore/QuartzCore.h>并添加QuartzCore.framework.添加此导入后,CALayer将完全定义.