Question

Having the following html string to load in a uiwebview, i need to set the font-size as a variable value :

    NSString * htmlString = [NSString stringWithFormat:@"\
                             <html>\
                             <style type='text/css'>\
                             hr{ height: 0;border-bottom: 2px dotted #000;}\
                             .Prim{color:#000000; direction:ltr;font-size:%d;font-weight:bold;}\
                             .Def_en{direction:ltr;font-size:%d}\
                             .Def_ar{direction:rtl;font-size:%d}\
                             </style>\
                             <table width='100%%'>\<tr>\<td>\
                             <body>\
                             <p style = 'font-size:%dpx;'> %@ <\p>\
                             </td></tr><tr><td><br><br></td></tr><tr><td align ='center'><br><img src='%@' width='60%%' \><br></td></tr></body>\
                             </table>\
                             </html>",textFontSize , authorNAme , cachePath];

This code is how i imagined it to be but it didn't work..what should i change in order of giving the font-size attribute the value of a variable textFontSize ?
Thank you in advance

Was it helpful?

Solution

i actually found the problem and it was as simple as it can be...here's the code :

NSString * htmlString = [NSString stringWithFormat:@"\
                         <html>\
                         <style type='text/css'>\
                         hr{ height: 0;border-bottom: 2px dotted #000;}\
                         .Prim{color:#000000; direction:ltr;font-size:%d;font-weight:bold;}\
                         .Def_en{direction:ltr;font-size:%d}\
                         .Def_ar{direction:rtl;font-size:%d}\
                         </style>\
                         <table width='100%%'>\<tr>\<td>\
                         <body>\
                         <p style = 'font-size:%dpx;'> %@ <\p>\
                         </td></tr><tr><td><br><br></td></tr><tr><td align ='center'><br><img src='%@' width='60%%' \><br></td></tr></body>\
                         </table>\
                         </html>",textFontSize+12,textFontSize,textFontSize,textFontSize,authorNAme , cachePath];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top