如何知道文本的方向? [英] How to know the direction of the text?

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

问题描述

在 UITextView 中键入时,我需要根据键盘的语言知道文本的方向.例如,如果用户用英语输入,则方向为从左到右",如果用户用阿拉伯语输入,则方向为从右到左".我毫无疑问需要这个值,并避免硬编码每种语言与其文本方向之间的匹配.

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.

这可能吗?

推荐答案

UITextInput 协议:

- (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 实现了这样的协议.

UITextView implements such protocol.

这篇关于如何知道文本的方向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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