UITextField 基本設置

_myAccount = [[UITextField alloc]init];
    _myAccount.frame =  CGRectMake(0, 0, 200, 100);
    _myAccount.backgroundColor = [UIColor clearColor];
    [_myAccount.layer setCornerRadius:4];
    //設置輸入框的顏色
    CGColorRef cgColor = [UIColor grayColor].CGColor;
    _myAccount.layer.borderColor = cgColor;
    //輸入框像左空幾格 40
    UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0,40, 0)];
    _myAccount.leftView = paddingView;
    _myAccount.leftViewMode = UITextFieldViewModeAlways;  //居中
    _myAccount.layer.borderWidth= 1.0f;
    _myAccount.delegate = self;
    _myAccount.placeholder = @"請輸入帳號或手機號";
    _myAccount.font = [UIFont systemFontOfSize:17];
    _myAccount.clearButtonMode = UITextFieldViewModeWhileEditing;
    _myAccount.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter;
    [_myLoginView addSubview:_myAccount];
相關文章
相關標籤/搜索