How to apply bold for string in html format in iOS? -
i want print text in bold using string prints in compose mail app
messagebody = [nsstring stringwithformat:@"<b>background information</b>"];
what use nsattributedstring. nsstring *boldfontname = [[uifont boldsystemfontofsize:12] fontname]; nsstring *yourstring = ...; nsrange boldedrange = nsmakerange(22, 4); nsmutableattributedstring *attrstring = [[nsmutableattributedstring alloc] initwithstring:yourstring]; [attrstring beginediting]; [attrstring addattribute:kctfontattributename value:boldfontname range:boldedrange]; [attrstring endediting]; //draw attrstring here... or use code not want bother fonts (as not every variation of font contains "bold"), here way this: nsmutableattributedstring *attrstring = [[nsmutableattributedstring alloc] initwithstring:"approximate distance: 120m away"]; [attrstring beginediting]; [attrstring applyfonttraits:nsboldfontmask range:nsmakerange(22, 4)]; [attrstring endediting];
Comments
Post a Comment