UITextView占位符

self.textView.delegate = self;
//开始编辑

  • (void)textViewDidBeginEditing:(UITextView *)textView {
    if ([self.textView.text isEqualToString:@""]) {
    textView.text = @"";
    self.textView.textColor = [UIColor blackColor];
    }
    }
    //在结束编辑的代理方法中进行如下操作
  • (void)textViewDidEndEditing:(UITextView *)textView {
    if (textView.text.length<1) {
    self.textView.text = @"";
    self.textView.textColor = colorText;
    }
    }

你可能感兴趣的:(UITextView占位符)