2013-10-06 26 views

回答

1

如果您只需要³,则可以使用适当的Unicode字符(Unicode:U + 00B3,UTF-8:C2 B3)。在Mac上,您可以使用“字符查看器”(例如在“编辑”菜单 - “特殊字符”),在搜索框中输入“3”,然后抓取相应的“相关字符”。有关更多信息,请参阅Apple帮助文档entering unicode characters

如果您需要更广泛的下标使用(或者您需要更细致地控制上标的呈现方式),您可以使用属性字符串。因此,下面将呈现类似 “千米”:

UIFont *font = [UIFont fontWithName:self.label.font.familyName size:self.label.font.pointSize * 0.75]; 
NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"1,000 m3"]; 
NSDictionary *attributes = @{(id)kCTSuperscriptAttributeName : @(1), 
          (id)NSFontAttributeName   : font}; 
[string addAttributes:attributes range:NSMakeRange(7, 1)]; 
+0

谢谢你们,非常有帮助。 – IainGM

+0

或者只使用Unicode字符作为上标3 - '³'。 – rmaddy

+0

同意。我认为这是其他答案所暗示的,所以我在这里没有重复。 – Rob

1

使用编辑>特殊字符...(在搜索框中键入“立方”),只需将字符串字面量的符号:

textField.text = [NSString stringWithFormat:@"Your table is %u㎤", tableVolume); 

这是我发现单位立方符号:

㎣㎤㎥㎦

如果想有一个通用的标 '3' 那么将很难安排......

+0

有一个上标3(³)。这是字符U + 00B3。这允许例如'm³'。 – rmaddy

+0

@rmaddy谢谢;我找不到它。 – trojanfoe

相关问题