How to know the direction of the text?

泄露秘密 提交于 2020-01-03 16:51:15

问题


I need to know the direction of a text depending on the language of the keyboard when typing in a UITextView. For example, if the user is typing in english, then the direction will be "left to right" and if the user is typing in arabic, "right to left". I need that value without doubts and avoiding to hardcoding a matching between each language and its text direction.

Is this possible?


回答1:


Check this out this method from UITextInput Protocol:

- (UITextWritingDirection)baseWritingDirectionForPosition:(UITextPosition *)position inDirection:(UITextStorageDirection)direction

This returns a constant that represents a writing direction (for example, left-to-right or right-to-left)

UITextView implements such protocol.



来源:https://stackoverflow.com/questions/11305791/how-to-know-the-direction-of-the-text

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!