热门搜索 :
考研考公
您的当前位置:首页正文

UITextView添加placeholder

来源:东饰资讯网

使用UITextView 代理方法

- (void)textViewDidBeginEditing:(UITextView *)textView { 
  if ([textView.text isEqualToString:@"placeholder text here..."]) { 
      textView.text = @""; 
      textView.textColor = [UIColor blackColor]; //optional 
   }
  [textView becomeFirstResponder];
}
- (void)textViewDidEndEditing:(UITextView *)textView { 
  if ([textView.text isEqualToString:@""]) { 
      textView.text = @"placeholder text here..."; 
      textView.textColor = [UIColor lightGrayColor]; //optional 
  } 
  [textView resignFirstResponder];
}
Top