当前位置: 代码迷 >> 综合 >> IOS UITextView 提交建议反馈
  详细解决方案

IOS UITextView 提交建议反馈

热度:81   发布时间:2023-12-15 02:16:51.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 = @"";}
}