I am creating HTML using following code:
NSString *string = [NSString stringWithFormat:
@"<html> \n" "<head> \n"
"<style type=\"/css\"> \n"
"body {font-family: \"%@\"; font-size: %@;}\n"
"</style> \n"
"</head> \n"
"<body>%@</body> \n"
"</html>",@"Helvetica",[NSNumber numberWithInt:17],
@"<p><i>My data</p>"];
Here I am giving [NSNumber numberWithInt:17]
for font size but any change in this 17
dosen't making changes in font size of HTML.
What should I do?
You need a unit attached to it. the CSS font-size property needs to be
font-size: 17px
or you could also use em or percentages
I think your problem was that you had the wrong style type – /css
and not text/css
.
"<style type=\"text/css\"> \n"
Passing [NSNumber numberWithInt:17];
doesn't passes the actual value, it just passes the object reference. So, you should be passing it like this,
font-size: %dpx;
And the value as just,
17
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.