IOS UITextView加上placeholder
来源:互联网 发布:信用卡垫还 app 源码 编辑:程序博客网 时间:2024/05/17 23:51
UITextView上如何加上类似于UITextField的placeholder呢,其实在UITextView上加上一个UILabel,然后再实现
说明如下:
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text这个代理方法就可以了。
具体实现如下:
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{ if (![text isEqualToString:@""]) { _label1.hidden = YES; } if ([text isEqualToString:@""] && range.location == 0 && range.length == 1) { _label1.hidden = NO; } return YES;}
说明如下:
(1) _label1 是加在UITextView上的UILabel
(2) [text isEqualToString:@""] 表示输入的是退格键
(3) range.location == 0 && range.length == 1 表示输入的是第一个字符
效果如下:
0 0
- IOS UITextView加上placeholder
- iOS UITextView加上placeholder
- IOS UITextView加上placeholder
- IOS UITextView加上placeholder
- ios UITextView placeHolder效果
- UITextView加上placeholder效果用UILabel
- iOS 实现UITextView的placeholder
- 【iOS】UITextView中添加 placeholder
- 解决iOS UITextView没有placeholder
- iOS-UITextView占位文字placeholder
- iOS给UITextView添加Placeholder
- ios UITextView 添加水印提示(Placeholder)
- ios UITextView的placeHolder的设置
- ios UITextView的placeholder属性实现
- iOS开发:设置UITextView的placeholder
- iOS UITextView 实现placeholder的方法
- IOS 一个带有placeholder的UITextView
- iOS 实现 UITextView placeHolder的占位文字
- SEO中最常见的几个错误:
- Ubuntu设置环境变量
- 【数据挖掘】分类之Naïve Bayes
- 看看iOS和安卓用户都对什么感兴趣
- Android压缩图片并保持不失真的高效方法以及为图片添加水印
- IOS UITextView加上placeholder
- MySQL 数据类型
- C#操作注册表 实现快捷启动程序
- csdn三爷四年工作经验总结面试技巧+评论
- ZOJ 2588 Burning Bridges 求无向图桥 边双连通裸题
- MyEclipse中Tomcat发布工程:Exploded location overlaps an existing deployment
- JNI介绍
- 杨广为了东征做了四年的准备
- 策略模式