objective c - iOS how to draw text in a UILabel using a non standard alignment -


this question has answer here:

i want put numbers in label alignment in image. none of label's alignment modes me.

the decimal digits should above centre line , between top margin. other digits should aligned in regular fashion. don't know "professional" name thing or sort of api can help.

can point me in direction or have example snippet?

thanks

enter image description here

enter image description here

use below code. have done using nsmutableattributedstring.

nsstring *str = @"$899.00"; nsmutableattributedstring *attrstring = [nsmutableattributedstring new];  nsmutableattributedstring *attrsuperscript = [[nsmutableattributedstring alloc] initwithstring:str]; [attrsuperscript addattribute:(nsstring*)kctsuperscriptattributename value:@"-1" range:nsmakerange(0, [str length] - 3)]; [attrsuperscript addattribute:nsfontattributename value:[uifont fontwithname:@"helveticaneue-thin" size:28] range:nsmakerange(0, [str length])]; [attrsuperscript addattribute:nsfontattributename value:[uifont fontwithname:@"helveticaneue-thin" size:15] range:nsmakerange([str length] - 3, 3)];  [attrstring appendattributedstring:attrsuperscript]; [attrstring addattribute:nsforegroundcolorattributename value:[uicolor greencolor] range:nsmakerange(0, [str length])];  uilabel *label = [[uilabel alloc] initwithframe:cgrectmake(20, 100, 200, 50)]; [label setattributedtext:attrstring]; [self.view addsubview:label]; 

a sample screen shot of output:

enter image description here


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -