字符串IOS中的上标字符 [英] superscript characters in string IOS

查看:1118
本文介绍了字符串IOS中的上标字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序在xcode中有一个tableview与一些产品数据。我的一个产品在其名称上有一个上标e。如何在字符串中使用上标字符,如:text e



我可以使用它处理数字:text\\\⁰ - > text 0 或text\\\ⁱ - > text 1 。但是如何使用其他字符呢?



thx!

解决方案

tl; dr:NSString不支持super / sub脚本的概念。这或多或少是一个UI格式化的问题。



一个可能的解决方案是在代码中动态添加UILabels,而不是在界面生成器中。您可以添加具有较小字体大小的第二个UILabel。


My app in xcode has a tableview with some product data. One of my products have a superscript e in its name. How can I use superscript characters in a string like: texte

I can get it to work with numbers: text\u2070 -> text0 or text\u2071 -> text1. But how to do this with other characters?

thx!

解决方案

tl;dr: NSString does not support concept of super/sub script. That's more or less a UI formatting concern.

One possible solution is to dynically add UILabels in code instead of interface builder. You can add a second UILabel with a smaller font size.

这篇关于字符串IOS中的上标字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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