You can do one thing..
this is .h file------>
#import <UIKit/UIKit.h>
#define fontRegular @"Helvetica Neue"
#define fontBold @"HelveticaNeue-Bold"
@interface ABCViewController : UIViewController <UITextFieldDelegate>
{
NSString *strReturn;
}
@property(nonatomic,retain)NSString *strReturn;
@end
this is .m file--->
#import "ABCViewController.h"
@implementation ABCViewController
@synthesize strReturn;
-(void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UITextField *txt_Fields= [[UITextField alloc]initWithFrame:CGRectMake(30, 0, 230, 44)];
txt_Fields.backgroundColor= [UIColor clearColor];
txt_Fields.delegate= self;
txt_Fields.clearButtonMode=YES;
txt_Fields.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
[txt_Fields setFont:[UIFont fontWithName:fontRegular size:20.0]];
[txt_Fields setTextColor:[UIColor colorWithRed:105.0/255 green:105.0/255 blue:105.0/255 alpha:1.0]];
txt_Fields.borderStyle=UITextBorderStyleBezel;
txt_Fields.returnKeyType = UIReturnKeyDone;
txt_Fields.keyboardType=UIKeyboardTypeURL;
txt_Fields.autocapitalizationType = UITextAutocapitalizationTypeNone;
[self.view addSubview:txt_Fields];
[txt_Fields release];
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
self.strReturn=[NSString stringWithFormat:@"%@%@",strReturn,string];
textField.text=[NSString stringWithFormat:@"%@*",textField.text];
NSLog(@"str:- %@",self.strReturn);
return NO;
}
Note:-
But In this case you will have to maintain string manually, Means You will have to store the string in a string variable, you can not take textfield.text, because it will return - "****". And you will have to manage so many things manuaaly....
4 回答
这不可能 . 此功能在Apple中不可用 .
请记住,这是一款带有小键盘的移动设备 . 显示按下瞬间按下的键只是向用户保证他们按下正确的键 . 另外,因为它是一个移动设备,用户应该是唯一一个看着屏幕的用户 . 如果用户正在使用AirPlay共享屏幕,则应在输入密码信息之前将其关闭 .
你可能会看到这个例子:https://github.com/Koolistov/Passcode我希望能帮到你 .