NSString中的后缀有序的后缀

NSString中有一种方式来输出st,nd和rd,但是以上标格式输出吗? 任何已知的unicode也许?

这似乎没有任何Unicode字符,但很容易做一个NSAttributedString ,将做的伎俩:

 NSDictionary * superscriptAttrs = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:1] forKey:NSSuperscriptAttributeName]; NSAttributedString * st = [[NSAttributedString alloc] initWithString:@"st" attributes:superscriptAttrs]; NSMutableAttributedString * premiere = [[NSMutableAttributedString alloc] initWithString:@"1"]; [premiere appendAttributedString:st]; // Don't forget to release everything when you're done with it! 

您可能还想要更改上标的字体大小。 这是通过在属性字典中包含NSFontAttributeName和适当的字体对象来实现的。 请注意, NSAttributedString仅适用于iOS 4.0及更高版本的iPhone(请参阅评论)。