您的位置:首页 > 产品设计 > UI/UE

IOS UITextView 提交建议反馈

2015-07-07 22:02 330 查看
</pre></p><pre name="code" class="html">利用UITextView 来提交多行内容的文字。
_contentTextView = [[UITextView alloc]initWithFrame:CGRectMake(0, 74, kDEVICEWIDTH, 240)];
_contentTextView.backgroundColor = [UIColor whiteColor];
_contentTextView.delegate = self;
_contentTextView.font = TextFont;
[self.view addSubview:_contentTextView];

_placeHolderLabel = [[UILabel alloc]init];
_placeHolderLabel.frame = CGRectMake(0, 5, kDEVICEWIDTH, 20);
_placeHolderLabel.text = @"建议";
_placeHolderLabel.enabled = NO;
_placeHolderLabel.backgroundColor = [UIColor clearColor];
_placeHolderLabel.font = TextFont;
[_contentTextView addSubview:_placeHolderLabel];


#pragma mark -- UITextFieldDelegate

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

if ([_contentTextView isFirstResponder])
{
[_contentTextView resignFirstResponder];
}
}

-(void)textViewDidChange:(UITextView *)textView
{
if (textView.text.length == 0) {
_placeHolderLabel.text = @"建议";
}else{
_placeHolderLabel.text = @"";
}
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: