会员访问不完整类型'CALayer'

Ani*_*mar 3 calayer mapkit ios

对于以下代码:

CGRect frame = CGRectMake(0, 0, cellWidth, 240);
MKMapView *mapView = [[MKMapView alloc] initWithFrame:frame];

mapView.layer.masksToBounds = YES;     
mapView.layer.cornerRadius = 10.0;
Run Code Online (Sandbox Code Playgroud)

我还包括MapKit,QuartzCore和CoreLocation框架.对于最后两行,我收到错误:"成员访问不完整类型'CALayer'"

请告诉我为什么我会收到此错误以及如何解决此问题

编辑:我得到这个错误,因为我没有导入Quartz.h,但我仍然不明白为什么它说CALayer类型的不完整性.任何人都可以深入了解这一点.

谢谢

Rui*_*res 6

你有没有#import <QuartzCore/QuartzCore.h>