从一个文件复制到另一个文件的代码将无法构建

时间:2012-05-21 21:38:06

标签: objective-c xcode4

我有一些代码可以在UITextView周围设置边框。它在一个类中正确构建;当我接受该代码并将其复制到另一个类(更改对象名称)时,它不再构建,说“在前向类对象'CALayer *'中找不到”属性'borderWidth'(其他两行的相同消息)代码)。我做了一个干净的,重新构建,没有任何帮助。为什么会这样?以及如何修复它?

- (void)viewDidLoad  {
[super viewDidLoad];

//--  draw box around notes field
orderNotes.layer.borderWidth = 1.0f;
orderNotes.layer.borderColor = [[UIColor blackColor] CGColor];
orderNotes.layer.cornerRadius = 4; 

}

对象“orderNotes”定义为UITextView。没有其他错误。

1 个答案:

答案 0 :(得分:11)

你需要:

#import <QuartzCore/QuartzCore.h>

否则,您无法看到layer属性。