objective c - Superscript cents in an attributed string -
i'm trying label so:
but using attributed string, managed result:
my code:
nsstring *string = [nsstring stringwithformat:@"%0.2f",ask]; nsmutableattributedstring *buystring = [[nsmutableattributedstring alloc] initwithstring:string]; [buystring addattribute:nsfontattributename value:[uifont systemfontofsize:15.0] range:nsmakerange(2, buystring.length - 2)]; self.labelbuy.attributedtext = buystring;
as see, numbers after dot, stay below, , pop them top first example. there way set attributed string frame?
you have use nsbaselineoffsetattributedname
.
from doc:
nsbaselineoffsetattributename
value of attributensnumber
object containing floating point value indicating character’s offset baseline, in points. default value 0.
available in ios 7.0 , later.
from example:
[buystring addattribute:nsbaselineoffsetattributename value:@(10.0) range:nsmakerange(2, buystring.length - 2)];
you may have change value fit needs.
Comments
Post a Comment