1 #import "AppDelegate.h"2 3 @interfaceAppdelegate () <UITextFieldDelegate>//Add an Agent agreement4 5 @end6 7 @implementationappdelegate8 9 Ten-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchoptions { OneSelf.window =[[UIWindow alloc] initwithframe:[[uiscreen mainscreen] bounds]; A //Override point for customization after application launch. -Self.window.backgroundColor =[Uicolor Whitecolor]; - the -Uitextfield *TF = [[Uitextfield alloc] Initwithframe:cgrectmake ( -, -, the, -)]; - //Confirm Agent -Tf.Delegate=Self ; +Tf.keyboardtype =Uikeyboardappearancedefault; - +Tf.backgroundcolor =[Uicolor Greencolor]; A [Self.window ADDSUBVIEW:TF]; at - [Self.window makekeyandvisible]; - returnYES; - } - --(BOOL) TextField: (Uitextfield *) TextField Shouldchangecharactersinrange: (nsrange) range replacementstring: ( NSString *)string in { - intLength =[Textfield.text length]; to //2 represents the start position of the *, and 9 for the end position of the * number + if(Length >2&& Length <9) { -Nsmutablestring *text =[Textfield.text mutablecopy]; the[Text Replacecharactersinrange:nsmakerange (Length-1,1) Withstring:@"*"]; *Textfield.text =text; $ }Panax Notoginseng returnYES; - } the + @end
The effect of the implementation is as follows:
Uitextfield text box Part text is displayed in a * way