UITextField实现PlaceHolder
2016-03-06 17:21
417 查看
@interface
ViewController () <UITextViewDelegate>
{
UITextView *_textView1;
UILabel *_label1;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super
viewDidLoad];
//首先定义UITextView
_textView1 = [[UITextView
alloc] init];
_textView1.font = [UIFont
systemFontOfSize:14];
_textView1.frame =CGRectMake(10,
30, 200,
300);
_textView1.autoresizingMask =
UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
_textView1.backgroundColor = [UIColor
whiteColor];
[self.view
addSubview:_textView1];
_textView1.hidden =
NO;
_textView1.delegate =
self;
//其次在UITextView上面覆盖个UILable,UILable设置为全局变量。
_label1 = [[UILabel
alloc ] initWithFrame:CGRectMake(10,
30,
40, 30)];
_label1.text =
@"请填写审批意见...";
_label1.enabled =
NO;//lable必须设置为不可用
_label1.backgroundColor = [UIColor
clearColor];
[self.view
addSubview:_label1];
}
#pragma mark - 实现UITextView的代理
-(void)textViewDidChange:(UITextView *)textView
{
_textView1.text = textView.text;
if (textView.text.length ==
0)
{
_label1.text =
@"请填写审批意见...";
}else
{
_label1.text =
@"";
}
}
ViewController () <UITextViewDelegate>
{
UITextView *_textView1;
UILabel *_label1;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super
viewDidLoad];
//首先定义UITextView
_textView1 = [[UITextView
alloc] init];
_textView1.font = [UIFont
systemFontOfSize:14];
_textView1.frame =CGRectMake(10,
30, 200,
300);
_textView1.autoresizingMask =
UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
_textView1.backgroundColor = [UIColor
whiteColor];
[self.view
addSubview:_textView1];
_textView1.hidden =
NO;
_textView1.delegate =
self;
//其次在UITextView上面覆盖个UILable,UILable设置为全局变量。
_label1 = [[UILabel
alloc ] initWithFrame:CGRectMake(10,
30,
40, 30)];
_label1.text =
@"请填写审批意见...";
_label1.enabled =
NO;//lable必须设置为不可用
_label1.backgroundColor = [UIColor
clearColor];
[self.view
addSubview:_label1];
}
#pragma mark - 实现UITextView的代理
-(void)textViewDidChange:(UITextView *)textView
{
_textView1.text = textView.text;
if (textView.text.length ==
0)
{
_label1.text =
@"请填写审批意见...";
}else
{
_label1.text =
@"";
}
}
相关文章推荐
- Unexpected Exception caught setting 'x' on class xx:Error setting expression 'xx' with value ['x',]
- UIActivity头文件学习
- swif之UITableViewCell和UITableView常见属性复习
- POJ 3061 Subsequence【尺取法】
- 错误svn: The repository at 'svn://xxxxx' has uuid 'XXXX', but the WC has 'XXXX'“
- Qt中ui文件的使用
- SharePoint 2010 - Hardware and Software Requirements
- Binary Expression and Value Expression
- UIActivityIndicatorView的使用
- 如何设置约束让三个按钮平分UIView容器的宽度的方法
- UIActivityViewController头文件学习
- Android UI优化
- 1051. Pop Sequence (25) 判断出栈序列是否合理
- [LeetCode]62. Unique Paths
- LA 4287(p322)----Proving Equivalences
- 一起看代码来玩玩QT之18 database (last QSqlQueryModel 对数据库进行操作(只查不能改)QTableModel 可改,但是QSqlQueryModel也可以添加代理等功)
- Maximum Subsequence Sum
- hdoj 2734 Quicksum(字符串)
- [LeetCode] Closest Binary Search Tree Value II 最近的二分搜索树的值之二
- 关于UEditor配合TP框架使用