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

Popular posts from this blog

c - CUDA code not processing if block properly -

oracle11g - get root domain from url Oracle sql regex_substr -

xcode - Swift Playground - Files are not readable -