2011-04-14 15 views

Respuesta

39

Use la cadena literal: \u00B0. Para caracteres Unicode, siempre estará "\ u" seguido del código de carácter.

NSString *temperature = [NSString stringWithFormat:@"65%@", @"\u00B0"]; 
+0

¿Cómo podemos hacer esto en IB? –

+1

@ OlcayErtaş: Debería poder pegar ° en el campo. –

5

Sólo que esta respuesta es muy útil, pero aún puede abreviarse como la siguiente (explica por sí mismo):

NSString *temperature = @"65\u00B0"; 
17

Ésta es la forma en que lo haría utilizando Swift:

var temperature = "65\u{00B0}" // degree symbol 
0
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; 
Cuestiones relacionadas