Automatically align text in UILabel according to text language

后端 未结 5 570
-上瘾入骨i
-上瘾入骨i 2021-02-04 19:59

I\'m interested in setting some text into a UILabel, and depending on the directionality of the language (e.g., Hebrew - right-to-left [RTL], English - left-to-righ

5条回答
  •  借酒劲吻你
    2021-02-04 20:45

    In HTML5 this can be done by applying dir="auto" to the element. It's implemented in WebKit, though I'm not completely sure that it's available in iOS.

    dir="auto" is very simple, and you can probably implement it yourself - just search for the first character that has strong directionality, and apply its directionality to the whole thing.

    If you can't find anything in iOS, you can try to take some smarter ideas from the way StatusNet implemented it: http://status.net/sites/default/files/issues/1346_jquery.directionDetector.js

提交回复
热议问题