NSString 中的上标序数后缀
NSString 有没有办法以上标格式输出 st、nd 和 rd?也许有任何已知的 unicode 吗?
Is there a way in NSString to output the st, nd, and rd but in a superscripted format? Any known unicode perhaps?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
似乎没有任何 Unicode 字符,但制作一个
NSAttributedString
就可以了窍门:您可能还想更改上标的字体大小。这是通过在属性字典中包含带有适当字体对象的
NSFontAttributeName
来实现的。请注意,NSAttributedString
仅适用于 iOS 4.0+ 的 iPhone 和 3.2+ 的 iPad(请参阅评论)。There doesn't seem to be any Unicode characters for this, but it's easy enough to make an
NSAttributedString
that will do the trick:You might also want to change the font size of the superscript. This is accomplished by including the
NSFontAttributeName
in the attributes dictionary with an appropriate font object. Note thatNSAttributedString
is only available on the iPhone in iOS 4.0+, and on the iPad in 3.2+ (see comment).