为 textView 添加 placeholder
//自定义一个 placeholder 样式的 label
UILabel*placeholder = [[UILabelalloc]init];
placeholder.text=@"请输入您的评价";
placeholder.numberOfLines=0;
placeholder.textColor=kColor(153,153,153);
[placeholdersizeToFit];
placeholder.font=kRegularFont(10);
UITextView*textView = [[UITextViewalloc]initWithFrame:CGRectMake(15,143,SCREEN_WIDTH-30,48)];
textView.backgroundColor=kColor(245,245,245);
textView.textColor=kColor(153,153,153);
textView.font=kRegularFont(10);
[textViewsetValue:placeholderforKey:@"_placeholderLabel"]; //这句话必须写
[textViewaddSubview:placeholder]; // 这句话必须写
[self.mainScrolladdSubview:textView];
网友评论