Property cannot be found on forward class object?

匿名 (未验证) 提交于 2019-12-03 01:47:02

问题:

I have a UIView and I'm trying to set its layer properties.

self.colorSwatch = [[UIView alloc] initWithFrame:CGRectMake(400, 150, 100, 100)]; self.colorSwatch.layer.cornerRadius = 8; 

However, when I try to access the .layer.cornerRadius property, I get a warning that says "Property 'cornerRadius' cannot be found in forward class object 'CALayer *'.

What does this mean? Thanks

回答1:

It doesn't know what type of object the layer property is. Add #import to the top of your file.



回答2:

You need to import the file #import < QuartzCore/QuartzCore.h> in ViewController.m class if and only if xcode version is less than 5.

See if you are using xcode version 5 or latest than that then not required to import .It is automatically included.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!