在编辑UITextField时,文本会跳转

时间:2015-03-30 09:52:50

标签: ios uitextfield

我以编程方式创建UITextField,当我点击它并开始编辑文本时,文本会向上跳几个像素然后向下(每次单击)。当我完成编辑时,它会转到中心,它实际上就是在那里。

self.phoneTextField = [[UITextField alloc]initWithFrame:CGRectMake(0, 0, quarterScreen * 3.0f, textFieldHeight)];
    self.phoneTextField.layer.borderColor = [[UIColor blackColor] CGColor];
    self.phoneTextField.layer.borderWidth = 1.0f;
    self.phoneTextField.textAlignment = NSTextAlignmentCenter;
    self.phoneTextField.placeholder = @"Enter Phone Here...";
    self.phoneTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    [self.phoneTextField becomeFirstResponder];
    self.phoneTextField.keyboardType = UIKeyboardTypeNumberPad;
    [self.phoneTextField setFont:[UIFont boldSystemFontOfSize:20]];
    [self addSubview:self.phoneTextField];

任何人都可以帮我解决这个问题吗?感谢。

0 个答案:

没有答案