uilabel - IOS Multiple right and left align on same line -


i want write on same line of tableview cell detailtextlabel.

for example left string right string.

i'm doing :

nsmutableattributedstring *descriptionattribute = [[nsmutableattributedstring alloc] initwithstring:descriptionstring]; nsmutableattributedstring *dateattribute = [[nsmutableattributedstring alloc] initwithstring:finaldate]; nsmutableattributedstring *shareattribute = [[nsmutableattributedstring alloc] initwithstring:@"share"];  nsmutableparagraphstyle *datestyle = [[nsparagraphstyle defaultparagraphstyle] mutablecopy]; [datestyle setalignment:nstextalignmentleft]; nsmutableparagraphstyle *sharestyle = [[nsparagraphstyle defaultparagraphstyle] mutablecopy]; [sharestyle setalignment:nstextalignmentright];  [dateattribute addattribute:nsforegroundcolorattributename value:[uicolor graycolor] range:nsmakerange(0, 13)]; [dateattribute addattribute:nsparagraphstyleattributename value:datestyle range:nsmakerange(0, 13)]; [shareattribute addattribute:nsforegroundcolorattributename value:[uicolor graycolor] range:nsmakerange(0, 8)]; [shareattribute addattribute:nsparagraphstyleattributename value:sharestyle range:nsmakerange(0, 5)];  [descriptionattribute appendattributedstring:[dateattribute mutablecopy]]; [descriptionattribute appendattributedstring:[shareattribute mutablecopy]];  mytableviewcell.detailtextlabel.attributedtext = descriptionattribute; 

if add \n between date , share attribute string, result good.

but want have 2 string on same line..

an idea ?

thanks

try

added nskernattributename after date

nsmutableattributedstring *descriptionattribute = [[nsmutableattributedstring alloc] initwithstring:@"hello how you"];     nsmutableattributedstring *dateattribute = [[nsmutableattributedstring alloc] initwithstring:@"\nfinal datetime"];     nsmutableattributedstring *shareattribute = [[nsmutableattributedstring alloc] initwithstring:@"share"];        nsmutableparagraphstyle *datestyle = [[nsparagraphstyle defaultparagraphstyle] mutablecopy];      [datestyle setalignment:nstextalignmentleft];     nsmutableparagraphstyle *sharestyle = [[nsparagraphstyle defaultparagraphstyle] mutablecopy];     [sharestyle setalignment:nstextalignmentright];      [dateattribute addattribute:nsforegroundcolorattributename value:[uicolor graycolor] range:nsmakerange(0, dateattribute.length)];     [dateattribute addattribute:nsparagraphstyleattributename value:datestyle range:nsmakerange(0, 13)];     [dateattribute addattribute:nskernattributename value:@170 range:nsmakerange(dateattribute.length-1, 1)];      [shareattribute addattribute:nsforegroundcolorattributename value:[uicolor graycolor] range:nsmakerange(0, 2)];     [shareattribute addattribute:nsparagraphstyleattributename value:sharestyle range:nsmakerange(0, 5)];        [descriptionattribute appendattributedstring:[dateattribute mutablecopy]];      [descriptionattribute appendattributedstring:[shareattribute mutablecopy]];      thecell.detailtextlabel.attributedtext = descriptionattribute; 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -