- ( void ) viewDidLoad {//...comments . text = @"请输入:" ;comments . textColor = [ UIColor lightGrayColor ];isEmpty = YES ;//...}
- ( BOOL ) textViewShouldBeginEditing: ( UITextView * ) textView {if ( isEmpty ) {comments . text = @"" ;comments . textColor = [ UIColor blackColor ];isEmpty = NO ;}return YES ;}
- ( void ) textViewDidEndEditing: ( UITextView * ) textView {if ( comments . text . length == 0 ){comments . textColor = [ UIColor lightGrayColor ];comments . text = @"请输入:" ;isEmpty = YES ;}}注意:需要在.h文件种添加协议< UITextViewDelegate>,在.m文件种设置协议 comments.delegate=self;
带提示(hint)的多行文本输入--UITextView
最新推荐文章于 2020-04-27 11:33:53 发布