UITextfield常用属性

@property(nonatomic,strong) UIImageView*bgImageView;//登录背景
@property(nonatomic,strong) UITextField*phoneNumField;//手机号输入框
@property(nonatomic,strong) UITextField*passwordField;//密码输入框


    //背景图
    _bgImageView = [[UIImageView alloc]initWithFrame:self.view.frame];
    _bgImageView.userInteractionEnabled = YES;
    _bgImageView.backgroundColor = [UIColor grayColor];
    _bgImageView.image = [UIImage imageNamed:@""];
    [self.view addSubview:_bgImageView];

    //手机号输入框
    _phoneNumField = [[UITextField alloc] initWithFrame:CGRectMake(0.0f, 80.0f, ScreenWidth, 50.0f)];
    [_phoneNumField setBorderStyle:UITextBorderStyleNone]; //外框类型

    _phoneNumField.placeholder = @"请输入账号"; //默认显示的字
    _phoneNumField.backgroundColor = [UIColor whiteColor];
    _phoneNumField.secureTextEntry = NO; //密码

    _phoneNumField.autocorrectionType = UITextAutocorrectionTypeNo;
    _phoneNumField.autocapitalizationType = UITextAutocapitalizationTypeNone;
    _phoneNumField.returnKeyType = UIReturnKeyDone;
    _phoneNumField.clearButtonMode = UITextFieldViewModeWhileEditing; //编辑时会出现个修改X

    _phoneNumField.delegate = self;



    [_bgImageView addSubview:_phoneNumField];

    //手机号label
    UILabel*phoneLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 0, 80, 50)];
    phoneLabel.text = @"账号";
    phoneLabel.textAlignment = NSTextAlignmentLeft;
    phoneLabel.textColor = [UIColor blackColor];
    phoneLabel.font = [UIFont systemFontOfSize:13];


    UIView*phoneLeftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 80, 50)];
    phoneLeftView.backgroundColor = [UIColor redColor];
    [phoneLeftView addSubview:phoneLabel];

    _phoneNumField.leftViewMode=UITextFieldViewModeAlways;
    _phoneNumField.leftView=phoneLeftView;

    //发送验证码
    UIButton*button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, 0, 80, 50);
    NSMutableAttributedString *content = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"发送验证码"]];
    NSRange contentRange = {0,[content length]};
    [content addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:contentRange];
    [button setAttributedTitle:content  forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize:13];
    UIView*phoneRightView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 80, 50)];
    phoneRightView.backgroundColor = [UIColor yellowColor];
    [phoneRightView addSubview:button];

    _phoneNumField.rightViewMode=UITextFieldViewModeAlways;
    _phoneNumField.rightView=phoneRightView;

    //密码输入框
    _passwordField = [[UITextField alloc] initWithFrame:CGRectMake(0.0f, 130.5f, ScreenWidth, 50.0f)];
    [_passwordField setBorderStyle:UITextBorderStyleNone]; //外框类型

    _passwordField.placeholder = @"6-12位数字或字母"; //默认显示的字
    _passwordField.backgroundColor = [UIColor whiteColor];
    _passwordField.secureTextEntry = YES; //密码

    _passwordField.autocorrectionType = UITextAutocorrectionTypeNo;
    _passwordField.autocapitalizationType = UITextAutocapitalizationTypeNone;
    _passwordField.returnKeyType = UIReturnKeyDone;
    _passwordField.clearButtonMode = UITextFieldViewModeWhileEditing; //编辑时会出现个修改X

    _passwordField.delegate = self;



    [_bgImageView addSubview:_passwordField];
    //登录密码label
    UILabel*passwordLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 0, 80, 50)];
    passwordLabel.text = @"密码";
    passwordLabel.textAlignment = NSTextAlignmentLeft;
    passwordLabel.textColor = [UIColor blackColor];
    passwordLabel.font = [UIFont systemFontOfSize:13];

    UIView*passwordLeftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 80, 50)];
    passwordLeftView.backgroundColor = [UIColor redColor];
    [passwordLeftView addSubview:passwordLabel];

    _passwordField.leftViewMode=UITextFieldViewModeAlways;
    _passwordField.leftView=passwordLeftView;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值