Cap*_*GUY 4 objective-c uikit ios swift
self.descriptionTextView.textAlignment = NSTextAlignment.Center
println(self.descriptionTextView.textAlignment.rawValue)
Run Code Online (Sandbox Code Playgroud)
写
4
表示默认的textAlignment值(NSTextAlignment.Natural).
我在故事板中创建了UITextView,并使用右侧的按钮手动将对齐设置为Center.
当我运行应用程序时,文本继续来自左侧.
有人知道为什么会这样吗?
(我使用的是最新版本的XCode,使用UITextField时似乎没有这种情况)
Cap*_*GUY 10
与UITextField不同,您无法在编辑UITextView的文本之前设置textAlignment.设置对齐后设置text属性是个问题.
请务必设置文本,然后按如下方式对齐:
self.descriptionTextView.text = ""
self.descriptionTextView.textAlignment = NSTextAlignment.Center
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1159 次 |
| 最近记录: |