强制标签文本从左到右,同时包含一些从右到左的文本 [英] Forcing label text to left-to-right while including some right-to-left text

查看:64
本文介绍了强制标签文本从左到右,同时包含一些从右到左的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字符串د.إ.,它代表货币符号,是从 NSLocale(localeIdentifier:"ar_AE").objectForKey(NSLocaleCurrencySymbol)中获得的!字符串

I have a string د.إ. that represent a currency symbol and that I get from NSLocale(localeIdentifier: "ar_AE").objectForKey(NSLocaleCurrencySymbol) as! String

在我的 UILabel 中,当我将文本设置为 theSymbol + aNumber 时(我什至无法在此处写下它,它也被颠倒了),显示为 aNumber + theSymbol ,因为该符号最有可能由应该从右到左显示的字符串组成.

In my UILabel, when I set the text to theSymbol + aNumber (I cannot even write it down here, it gets reversed as well), it is displayed as aNumber + theSymbol as most probably the symbol is made of strings that should be displayed right-to-left.

无论符号是什么,如何强制我的标签从左到右显示?

How can I force my label to display this left-to-right, whatever the symbol is?

推荐答案

我找到了一种使其工作的方法:

I found a way to make it work:

label.text = "\u{202A}" + symbol + "\u{202C}" + "1234"

\ u {202A} 用于从左到右的嵌入,而 \ u {202C} 用于Pop-Directional-Formatting.

\u{202A} is for Left-to-Right Embedding and \u{202C} is for Pop-Directional-Formatting.

此处是一篇有关双向文本的好文章

Here is a good article about bidirectional text

这篇关于强制标签文本从左到右,同时包含一些从右到左的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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