xcode 在转发类对象上找不到属性?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9829371/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 23:45:38  来源:igfitidea点击:

Property cannot be found on forward class object?

iphoneiosxcodeipad

提问by user339946

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

我有一个 UIView,我正在尝试设置它的图层属性。

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

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

但是,当我尝试访问该.layer.cornerRadius属性时,我收到一条警告,指出“在前向类对象‘CALayer *’中找不到属性‘cornerRadius’。

What does this mean? Thanks

这是什么意思?谢谢

回答by Jim

It doesn't know what type of object the layerproperty is. Add #import <QuartzCore/QuartzCore.h>to the top of your file.

它不知道该layer属性是什么类型的对象。添加#import <QuartzCore/QuartzCore.h>到文件的顶部。

回答by Mukesh

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

当且仅当 xcode 版本小于 5 时,您需要在 ViewController.m 类中导入文件 #import <QuartzCore/QuartzCore.h>。

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

查看您使用的是 xcode 版本 5 还是最新版本,然后不需要导入。它会自动包含在内。