关闭

IOS UITextView 提交建议反馈

426人阅读 评论(0) 收藏 举报
分类:

</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 = @"";
    }
}


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:448279次
    • 积分:8993
    • 等级:
    • 排名:第2193名
    • 原创:440篇
    • 转载:214篇
    • 译文:0篇
    • 评论:37条
    最新评论