Uitextview on how to add a similar to the Uitextfield placeholder, in fact, add a uilabel on Uitextview, and then realize
-(BOOL) TextView: (uitextview *) TextView shouldchangetextinrange: (nsrange) range Replacementtext: (nsstring *) Text This proxy method is possible.
The specific implementation is as follows:
-(BOOL) TextView: (Uitextview *) TextView Shouldchangetextinrange: (nsrange) Range Replacementtext: (NSString *) text{ if (![ Text isequaltostring:@ ""]) { _label1.hidden = YES; } if ([Text isequaltostring:@ ""] && range.location = = 0 && Range.length = = 1) { _label1.hidden = NO;
} return YES;
The description is as follows:
(1) _label1 is added to the Uitextview on the Uilabel
(2) [text isequaltostring:@ ""] means the backspace bar is entered
(3) range.location = = 0 && Range.length = = 1 indicates the first character entered
The effect is as follows:
IOS Uitextview Plus placeholder