{
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(0, 100, [UIScreen mainScreen].bounds.size.width, 100];
[textView setBackgroundColor:[UIColor greenColor]];
[self.view addSubview:textView];
// _placeholderLabel
UILabel *placeHolderLabel = [[UILabel alloc] init];
placeHolderLabel.text = @"請輸入內(nèi)容";
placeHolderLabel.numberOfLines = 0;
placeHolderLabel.textColor = [UIColor lightGrayColor];
[placeHolderLabel sizeToFit];
[textView addSubview:placeHolderLabel];
// same font
textView.font = [UIFont systemFontOfSize:13.f];
placeHolderLabel.font = [UIFont systemFontOfSize:13.f];
[textView setValue:placeHolderLabel forKey:@"_placeholderLabel"];
}
通過修改textView原生的API來實現(xiàn)沒有placeholder問題
轉(zhuǎn)自:http://www.reibang.com/p/9edb8be75e0b