简体   繁体   中英

How we put style sheet in head tag in objective c

I want to insert style tag in to html. MY style tag is finalstyle i want to insert insert in mailbody head . This code not work for me. The final style not embeded.

this my style

$1<div ><style type="text/css"> p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px 'Helvetica Neue'} span.s1 {font-family: 'Helvetica Neue'; font-weight: bold; font-style: normal; font-size: 15.00px; text-decoration: underline} </style></div><br /><div style="border-left: 1px solid grey; padding-left: 15px"> –



replacements = [NSString stringWithFormat:@"$1<div>%@</div><br /><div style=\"border-left: 1px solid grey; padding-left: 15px\">", finalstyle]; 

 NSRegularExpression *regexs = [NSRegularExpression regularExpressionWithPattern:@"(<head.*?>)" options:NSRegularExpressionCaseInsensitive error:&error];
            mailBody = [regexs stringByReplacingMatchesInString:mailBody options:0 range:NSMakeRange(0, [mailBody length]) withTemplate:replacements];;

it is working.

NSString *fileStyle=@"<style type=\"text/css\"> p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 25.0px 'Helvetica Neue'} span.s1 {font-family: 'Helvetica Neue'; font-weight: bold; font-style: normal; font-size: 15.00px; text-decoration: underline} </style>";

NSString *emailBody = [NSString stringWithFormat:@"<html><head>%@</head><body><p class=\"p1\">sesfes</p></body></html>", fileStyle];
NSRegularExpression *regexs = [NSRegularExpression regularExpressionWithPattern:@"(<p class=\"p2\".*?>)" options:NSRegularExpressionCaseInsensitive error:&error];
                mailBody = [regexs stringByReplacingMatchesInString:mailBody options:0 range:NSMakeRange(0, [mailBody length]) withTemplate:replacements];;
        NSLog(@"%@",mailBody);

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM