如何在字符串中添加度数符号?

| 我正在用Objective-C写作。 如何在字符串中添加度数符号?我知道它的Unicode:
00B0
和UTF8 ::1ѭ。     
已邀请:
使用字符串文字:
\\u00B0
。对于Unicode字符,它将始终为\“ \\ u \”,后跟字符代码。
NSString *temperature = [NSString stringWithFormat:@\"65%@\", @\"\\u00B0\"];
    
这是使用Swift的方式:
var temperature = \"65\\u{00B0}\" // degree symbol
    
刚发现这个非常有帮助的答案,但它甚至可以缩写为以下内容(自我解释):
NSString *temperature = @\"65\\u00B0\";
    
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@\"80\\u00b0c\"];
    [attributedString setAttributes:@{NSFontAttributeName : [UIFont fontWithName:@\"Helvetica-light\" size:40.0]
                                      , NSBaselineOffsetAttributeName : @22} range:NSMakeRange(2, 2)];
    //asign this as a 
examplelabel.attributedtext = attributedString;
    

要回复问题请先登录注册