UITextField(文本输入框)

//编辑一个用户名输入框

    mytextfield_name=[[UITextField alloc]initWithFrame:CGRectMake(10010020060)];

    mytextfield_name.tag=99;

    mytextfield_name.placeholder=@"请输入用户名";

    mytextfield_name.autocorrectionType=UITextAutocorrectionTypeYes;//自动改正弹出一个选择条

    mytextfield_name.autocapitalizationType=UITextAutocapitalizationTypeWords;//按单词首字母大写

    //UITextAutocapitalizationTypeNone  首字母不大写

    //UITextAutocapitalizationTypeWords  按单词首字母大写

    //UITextAutocapitalizationTypeSentences 按句子首字母大写

    //UITextAutocapitalizationTypeAllCharacters  全部大写

    mytextfield_name.autocapitalizationType=UITextAutocapitalizationTypeSentences;//按句子首字母大写

    mytextfield_name.clearButtonMode=UITextFieldViewModeWhileEditing;//编辑时出现消除按钮

    //UITextFieldViewModeNever 从不显示消除按钮

    //UITextFieldViewModeUnlessEditing 停止输入时显示消除按钮;

    //UITextFieldViewModeWhileEditing 编辑时显示消除按钮

    //UITextFieldViewModeAlways 一直显示消除按钮

    mytextfield_name.backgroundColor=[UIColor yellowColor];

    mytextfield_name.returnKeyType=UIReturnKeyEmergencyCall;

    [ self . view   addSubview : mytextfield_name ];

//编辑一个密码输入框

    mytextfield_secure=[[UITextField alloc]initWithFrame:CGRectMake(10030020060)];

    mytextfield_secure.tag=100;

    mytextfield_secure.placeholder=@"请输入密码";

    mytextfield_secure.secureTextEntry=YES;

    mytextfield_secure.returnKeyType=UIReturnKeyEmergencyCall;//键盘右下角按钮类型

    //清除按钮

    mytextfield_secure.clearButtonMode=UITextFieldViewModeWhileEditing;

    //将输入框设置成圆角矩形

    [mytextfield_secure setBorderStyle:UITextBorderStyleRoundedRect];

    mytextfield_secure.backgroundColor=[UIColor yellowColor];

//    //键盘类型

//    mytextfield_secure.keyboardType=UIKeyboardTypePhonePad;

    [self.view addSubview:mytextfield_secure];

//添加一个view图片

    UIImageView *imgV=[[UIImageView alloc]initWithFrame:CGRectMake(003030)];

    UIImageView *imgV1=[[UIImageView alloc]initWithFrame:CGRectMake(003030)];

    imgV1.image=[UIImage imageNamed:@"pencil"];

    imgV.image=[UIImage imageNamed:@"pencil"];

    

    mytextfield_secure.leftView=imgV1;

    mytextfield_secure.leftViewMode=UITextFieldViewModeAlways;

    mytextfield_name.leftView=imgV;

    mytextfield_name.leftViewMode=UITextFieldViewModeAlways;

    //添加代理

    mytextfield_name.delegate=self;

    mytextfield_secure.delegate=self;

    

    mytextfield_name.backgroundColor=[UIColor purpleColor];

    mytextfield_secure.backgroundColor=[UIColor blueColor];

//代理方法点击其他地方收回键盘

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{

    [textfield_name resignFirstResponder];

    [textfeild_dscore resignFirstResponder];

}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值