美文网首页
给UITextView添加Placeholder属性

给UITextView添加Placeholder属性

作者: 月巴成狗 | 来源:发表于2017-03-01 11:42 被阅读0次

    UITextView*textView = [[UITextViewalloc] initWithFrame:CGRectMake(20,100, [UIScreenmainScreen].bounds.size.width-20,120];   

     [textView setBackgroundColor:[UIColor greenColor]];  

      [self.view addSubview:textView];

    UILabel*placeHolderLabel = [[UILabelalloc] init];  

      placeHolderLabel.text =@"请输入建议或意见";   

     placeHolderLabel.numberOfLines =0;  

      placeHolderLabel.textColor = [UIColorlightGrayColor];   

     [placeHolderLabel sizeToFit]; 

       [textView addSubview:placeHolderLabel];

    fonttextView.font = [UIFontsystemFontOfSize:12];  

      placeHolderLabel.font = [UIFontsystemFontOfSize:12];  

      [textView setValue:placeHolderLabel forKey:@"_placeholderLabel"];

    相关文章

      网友评论

          本文标题:给UITextView添加Placeholder属性

          本文链接:https://www.haomeiwen.com/subject/edyqgttx.html