代码如下:

- (void)setupTextView
{
    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 = @"请输入内容";
    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"];
}

  

 

 

参考资料:http://www.jianshu.com/p/9edb8be75e0b

 

 

 


 转载请注明出处:http://www.cnblogs.com/ficow/p/7214387.html

 

相关文章:

  • 2022-12-23
  • 2022-01-22
  • 2022-12-23
  • 2021-11-24
  • 2022-02-03
  • 2021-05-16
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-09
  • 2021-11-06
  • 2021-07-07
相关资源
相似解决方案