UITextField textAlignment Center

时间:2015-02-04 08:20:49

标签: ios swift uitextfield alignment

这是我的代码,我想将字体大小更改为视图宽度,我正在改变,但对齐失真。

func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool
{
    inputText.contentVerticalAlignment = UIControlContentVerticalAlignment.Center
    inputText.contentHorizontalAlignment = UIControlContentHorizontalAlignment.Center
    inputText.textAlignment = NSTextAlignment.Center
    inputText.adjustsFontSizeToFitWidth = true

    return true
}

0 个答案:

没有答案