UILabels 和 Unicode

发布于 2024-11-04 21:05:27 字数 224 浏览 1 评论 0原文

我知道有人问过类似的问题,但我还没有找到满意的答案。

我正在尝试创建一个 UILabel 来显示方程式。不过,我不喜欢指数和下标有多个标签,因为我要进行计算,并且指数和下标的位置必须移动才能保持格式。相反,我想在 UILabel 中输入 Unicode 形式的上标和下标“n”(分别为 0x207F 和 0x2099),并在答案发生变化时让它们相应地移动。我已经搜索了一段时间了,但还没有找到答案。有办法做到这一点吗?

I know questions similar to this have been asked, but I haven't found a satisfactory answer.

I'm trying to create a UILabel to display an equation. I don't like having multiple labels for exponents and subscripts, though, because I'm going to be making calculations, and the positions of the exponents and subscripts will have to shift to maintain formatting. Instead, I'd like to enter in the Unicode forms of superscript and subscript 'n' (0x207F and 0x2099 respectively) within my UILabel, and have them shift accordingly when the answers change. I've been searching for a while now, and I haven't been able to find an answer. Is there a way to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冷夜 2024-11-11 21:05:27

您可以在 uilabel 中分配 unicode,如下所示 -

[yourLabel settext:@"\u207F and \u2099"];

you can assign a unicode in uilabel as follows -

[yourLabel settext:@"\u207F and \u2099"];
榆西 2024-11-11 21:05:27

您可以对 unicode 使用 %C 格式说明符。

myLabel.text = [NSString stringWithFormat:@"String with unicode %C", 0x207F];

You can use %C format specifier for unicode.

myLabel.text = [NSString stringWithFormat:@"String with unicode %C", 0x207F];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文