UITextView添加placeholder属性
2015-03-24 09:09
246 查看
1.先遵循UITextViewDelegate协议
2.设置全局变量textLable或者自定义一个UITextView,将lable设置为其属性
3.以下代码
#pragma mark -
#pragma mark 给UITextView添加placeholder
//
设置代理人
content.delegate =
self;
//
给UITextView添加标签
textLable = [[UILabel
alloc] initWithFrame:CGRectMake(10,
10,
300, 20)];
textLable.text =
@"请在此处输入正文";
textLable.enabled =
NO;
textLable.backgroundColor = [UIColor
clearColor];
[content
addSubview:textLable];
}
// 添加textView的方法
- (void)textViewDidChange:(UITextView *)textView
{
// NSLog(@"输出啦啦啦");
if (content.text.length ==
0) {
textLable.text =
@"请在此处输入正文";
}
else {
textLable.text =
@"";
}
}
2.设置全局变量textLable或者自定义一个UITextView,将lable设置为其属性
3.以下代码
#pragma mark -
#pragma mark 给UITextView添加placeholder
//
设置代理人
content.delegate =
self;
//
给UITextView添加标签
textLable = [[UILabel
alloc] initWithFrame:CGRectMake(10,
10,
300, 20)];
textLable.text =
@"请在此处输入正文";
textLable.enabled =
NO;
textLable.backgroundColor = [UIColor
clearColor];
[content
addSubview:textLable];
}
// 添加textView的方法
- (void)textViewDidChange:(UITextView *)textView
{
// NSLog(@"输出啦啦啦");
if (content.text.length ==
0) {
textLable.text =
@"请在此处输入正文";
}
else {
textLable.text =
@"";
}
}
相关文章推荐
- UITextView添加placeholder属性
- UITextView添加placeholder属性
- UITextView 添加placeholder
- 给UITextView添加PlaceHolder
- 如何给div添加placeholder属性
- iOS给UITextView添加Placeholder
- UITextview 给给定的字符串添加link属性 指定字符串添加点击方法
- 实现placeholder属性的UITextView
- UItextview 怎么实现placeholder属性
- DeveKing7-给UITextView添加Placeholder最简单易懂的方法
- 为form表单元素添加placeholder属性
- UITextView的placeholder属性
- 自定义 UITextView 的 placeholder 属性
- 教大家如何给UITextView添加placeholder扩展
- 实现placeholder属性的UITextView
- 为UITextField添加placeholder属性
- 如何给div添加placeholder属性
- TextView添加placeholder属性
- UITextView的字数限制 及 添加自定义PlaceHolder
- ios UITextView 添加水印提示(Placeholder)