ios UITestfiled

- (void)LY_Display 
{ 
    UILabel *Label = [[UILabel alloc] initWithFrame:CGRectMake(60, 180, 60, 30)]; 
    [self.view addSubview:Label]; 
    Label.backgroundColor = [UIColor clearColor]; 
    Label.text = @"密   码"; 
    Label.font= [UIFont fontWithName:@"zapfino" size:(15.0f)]; //字体设置 
    

    UITextField *Text = [[UITextField alloc] initWithFrame:CGRectMake(143, 180, 80, 30) ]; 
    [self.view addSubview:LY_Text]; 
    Text.backgroundColor = [UIColor whiteColor]; 
    [Text setBorderStyle:UITextBorderStyleLine];             //边框设置 
    Text.placeholder = @"password";                          //默认显示的字 
    Text.font = [UIFont fontWithName:@"helvetica" size:12];  //字体和大小设置 
    Text.textColor = [UIColor redColor];                     //设置字体的颜色 
    Text.clearButtonMode = UITextFieldViewModeWhileEditing;  //清空功能x 
    Text.returnKeyType = UIReturnKeyDone;                    //键盘有done 
    Text.secureTextEntry = YES;                              //密码输入时 
    Text.delegate = self;                                    //托管 
     
} 

委托事件

@protocol UITextFieldDelegate <NSObject>

@optional

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField;        // 返回NO则不许编辑

- (void)textFieldDidBeginEditing:(UITextField *)textField;           // became first responder

- (BOOL)textFieldShouldEndEditing:(UITextField *)textField;          // 返回YES允许结束并且resign first responder status. 返回NO不许编辑状态结束

- (void)textFieldDidEndEditing:(UITextField *)textField;             // 上面返回YES后执行;上面返回NO时有可能强制执行(e.g. view removed from window)

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string;   // 返回NO不改变

- (BOOL)textFieldShouldClear:(UITextField *)textField;               // clear button事件,返回NO过滤

- (BOOL)textFieldShouldReturn:(UITextField *)textField;              // 'return' key事件.返回NO过滤之

@end


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值