uitextview 实现placeholder

2023-04-26  本文已影响0人  wodeph

textView.text=@"Placeholder";

- (void)textViewDidBeginEditing:(UITextView*)textView {

 if([textView.text isEqualToString:HDLocalizedString(@"Placeholder")]) {

                textView.text=@"";

                textView.textColor= [UIColorblackColor];

    }

}

- (void)textViewDidEndEditing:(UITextView*)textView {

 if(textView.text.length<1) {

            textView.text = HDLocalizedString(@"Placeholder");

            textView.textColor= [UIColorlightGrayColor];

   }

}

上一篇 下一篇

猜你喜欢

热点阅读