2011-07-08 137 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帖子中這樣說。有時閱讀有助於:)這一次我太盲目了...... –