动态更改textview上的背景颜色

时间:2014-07-29 10:09:47

标签: ios objective-c uitextview

我有一个与此方法相关的编辑按钮。在这个方法中,我想使textView可编辑并更改背景。问题是背景似乎没有改变。那是为什么?

viewDidLoad中

self.aboutText.backgroundColor = [UIColor clearColor];
self.aboutText.delegate = self;
self.aboutText.editable = NO;

方法

-(IBAction)editField:(id)sender {

    self.aboutText.backgroundColor = [UIColor whiteColor];
    self.aboutText.editable = YES;



}

2 个答案:

答案 0 :(得分:0)

好的问题是我只设置了动作而不是目标。

我所做的只是将目标设定为自我。

抱歉给您带来不便

答案 1 :(得分:0)

尝试以下方法:

//。h file

@interface AddEntryViewController : UIViewController<UITextViewDelegate>{}

//。m file

  //viewDidLoad

  _aboutText.delegate = self;

 //add the following method

-(void) textViewDidBeginEditing:(UITextView *)textView
{
      [textView setTextColor: [UIColor blackColor]];
}
相关问题