我是靠谱客的博主 爱笑金毛,这篇文章主要介绍带提示(hint)的多行文本输入--UITextView,现在分享给大家,希望可以做个参考。

 
 
- ( 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的全部内容,更多相关带提示(hint)内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(127)

评论列表共有 0 条评论

立即
投稿
返回
顶部