objective c - Superscript cents in an attributed string -


i'm trying label so:

enter image description here

but using attributed string, managed result:

enter image description here

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 attribute nsnumber 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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -