UITextView的placeholder猥琐做法
来源:互联网 发布:java类初始化顺序 编辑:程序博客网 时间:2024/05/17 08:34
在UITextField中自带placeholder属性,可以用于提示输入框信息。但是UITextView并不具备此功能,经过自己的多次
尝试,终于发现了一种猥琐的做法。以下介绍在UITableView中的情况,XIB更简单,就不记录。
//首先定义UITextView UITextView *textView = [[UITextView alloc] init]; textView.font = [UIFont systemFontOfSize:14]; textView.frame =CGRectMake(10, 0, cell.contentView.bounds.size.width-20, side); textView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; textView.backgroundColor = [UIColor whiteColor]; [cell.contentView addSubview:textView]; textView.hidden = NO; textView.delegate = self; //其次在UITextView上面覆盖个UILable,UILable设置为全局变量。 uilabel.frame =CGRectMake(17, 8, cell.contentView.bounds.size.width - side+10, 20); uilabel.text = @"请填写审批意见..."; uilabel.enabled = NO;//lable必须设置为不可用 uilabel.backgroundColor = [UIColor clearColor]; [cell.contentView addSubview:uilabel];然后使用UITextView的代理,每当值改变的时候进行判断。
-(void)textViewDidChange:(UITextView *)textView{ self.examineText = textView.text; if (textView.text.length == 0) { uilabel.text = @"请填写审批意见..."; }else{ uilabel.text = @""; }}
只要这样就可以做一个类似placeholder的功能,是不是有眼前一亮的感觉。
- UITextView的placeholder猥琐做法
- UITextView实现placeholder的猥琐做法
- UITextView实现placeholder的猥琐做法
- UITextView 的placeholder
- UITextView 的placeholder
- UITextView的placeholder属性
- UITextView的placeholder属性
- UITextView的placeholder
- iphone自定义UITextView的placeholder
- UITextView 实现placeholder的方法
- UITextView 实现placeholder的方法
- 解决UITextView的placeholder属性
- UITextView 实现placeholder的方法
- iOS 实现UITextView的placeholder
- UITextView设置placeholder的方法
- UITextView 实现placeholder的方法
- UITextView 实现placeholder的方法
- 实现placeholder属性的UITextView
- 比较常用C库函数与WIN32函数
- SQL查询显示行号、随机查询、取指定行数据
- 模式对话框和非模式对话框MFC
- Wubi安装ubuntu空间不足
- EXP-00008: 导出表出现 ORACLE 错误 904 ORA-01003
- UITextView的placeholder猥琐做法
- C#在64位操作系统上用X86方式连接64位Oracle的问题和解决方案
- JSP页面
- javacript getter/setter
- NSSCanner:scanUpToString和scanString的区别
- greenDAO – Android ORM for SQLite
- error: macro names must be identifiers
- HTML5 Canvas 10个奇特的应用试验
- OpenLDAP:用ACL控制访问权限