iOS6系统下 textField 输入文本居中

适配iOS6系统时发现 textField输入框中的文字不再水平居中 而是靠上。解决问题的方法:

判断如果是6系统

            textField.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter;//垂直居中


这样就可以解决了。

关于textField文本位置设置:

typedef NS_ENUM(NSInteger, UIControlContentVerticalAlignment) {
    UIControlContentVerticalAlignmentCenter  = 0,
    UIControlContentVerticalAlignmentTop     = 1,
    UIControlContentVerticalAlignmentBottom  = 2,
    UIControlContentVerticalAlignmentFill    = 3,
};

typedef NS_ENUM(NSInteger, UIControlContentHorizontalAlignment) {
    UIControlContentHorizontalAlignmentCenter = 0,
    UIControlContentHorizontalAlignmentLeft   = 1,
    UIControlContentHorizontalAlignmentRight  = 2,
    UIControlContentHorizontalAlignmentFill   = 3,
};

你可能感兴趣的:(UI控件)