2011-07-08 52 views
4

我想添加四舍五入的Rects到UITextView中,如How to style UITextview to like Rounded Rect text field?中所解释的。但是,当我这样做时,我收到一条错误消息,找不到使用的方法。我觉得这很奇怪,因为它们还在文档中。另一方面,XCode在字段图层上自动完成时不显示任何内容。这个字段不知何故被弃用或者哪里可能是问题?我用CALayer似乎没有被定义

这里的两段代码:

@interface AddItemViewController : UIViewController {  
    IBOutlet UITextView *detailsTextView; 
} 
@end 

海尔将ICH丹恩死Eigenschaften aendern。

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // add rounded rects to detailsTextView 
    //first leads to warning that method is unknown 
    [detailsTextView.layer setCornerRadius:8.0f]; 
    // displays error that property is not found on object of type CALayer * 
    textView.layer.cornerRadius = 8.0f; 
    detailsTextView.clipsToBounds = YES; 
} 

回答

18

添加QuartzCore框架项目

在.h文件中包含该

#import <QuartzCore/QuartzCore.h> 
+1

谢谢你,我只是理解了它。它也在另一个stackoverflow帖子中这样说。有时阅读有助于:)这一次我太盲目了...... –