Uitextfield text box Part text is displayed in a * way

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.