问题描述
如何使用UTTextField获得合理的文本。它确实有一个textAlignment属性。但是UITextAlignment常数只有左,右和中心对齐。
How do I get justified text with UTTextField. It does have an textAlignment property. But the UITextAlignment constant only has left, right, and center justification.
我想要的是Justified文本常见的文字处理应用程序与文本同时左右边缘。这是一个只读文本字段。
What I am seeking is the Justified text common in word processing app with text flush with both left and right edges. This is a read only text field.
我在几个iPhone应用程序中看到了它。所以看来我错过了一些东西。
I have seen it in few iPhone apps. So it seems I am missing something.
推荐答案
UILabel和UITextField不支持全对齐文本。如果你想要一个UITextField,你必须创建一个UITextField的子类,并重写 drawTextInRect:
,将文本分割成单词,并使用 sizeWithFont:
UILabel and UITextField do not support full-justified text. If you want it for a UITextField, you would have to create a subclass of UITextField and override drawTextInRect:
, splitting the text into words and using sizeWithFont:
to figure out how to space them along each line.
我无法想象什么是值得的麻烦。
I cannot imagine what would be worth the trouble.
这篇关于在UITextField中获取对齐文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!