如何在Swift中居中UITextField文本 [英] How to center UITextField text in Swift

查看:115
本文介绍了如何在Swift中居中UITextField文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UITextField对象,其text属性设置为hi。但是这两行对hi的位置没有影响

I have a UITextField object with the text property set to "hi". However these two lines have no affect on where "hi" is located

 myUITextObject.contentVerticalAlignment = UIControlContentVerticalAlignment.Center
 myUITextObject.contentHorizontalAlignment = UIControlContentHorizontalAlignment.Center

这是Swift中的错误吗?如果是这样,我如何将此记录为一个错误,以便Apple可以在下一个Swift版本中修复它?

Is this a bug in Swift? If so how do I go about logging this as a bug so Apple can fix it in the next Swift release?

推荐答案

你会我想这样写:

myUITextObject.textAlignment = .center

(已编辑从.Center更改为.center)

(Edited to change from .Center to .center)

这篇关于如何在Swift中居中UITextField文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆