我如何垂直居中的UITextField的文本?文本、UITextField

由网友(浅念丶)分享简介:我只是实例化一个的UITextField ,并注意到,该文本不垂直居中。相反,它是我的按钮,我觉得,因为我希望默认垂直居中的一种奇怪的顶部齐平。我怎样才能居中垂直,或者是有,我错过了一些默认设置?解决方案 textField.contentVerticalAlignment = UIControlContentV...

我只是实例化一个的UITextField ,并注意到,该文本不垂直居中。相反,它是我的按钮,我觉得,因为我希望默认垂直居中的一种奇怪的顶部齐平。我怎样才能居中垂直,或者是有,我错过了一些默认设置?

解决方案

  textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
 

I am simply instantiating a UITextField and noticing that the text doesn't center vertically. Instead, it is flush with the top of my button, which I find kind of odd since I would expect the default to center it vertically. How can I center it vertically, or is there some default setting that I am missing?

解决方案 iOS开发1 UITextField控件属性

textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;

阅读全文

相关推荐

最新文章