Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何在目标c中的head标签中放置样式表_Html_Ios_Objective C_Regex_Ios8 - Fatal编程技术网

Html 如何在目标c中的head标签中放置样式表

Html 如何在目标c中的head标签中放置样式表,html,ios,objective-c,regex,ios8,Html,Ios,Objective C,Regex,Ios8,我想在html中插入样式标记。我的样式标签是我想插入邮件正文头的最后一个样式。这个代码对我不起作用。最终样式未嵌入 这是我的风格 $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:

我想在html中插入样式标记。我的样式标签是我想插入邮件正文头的最后一个样式。这个代码对我不起作用。最终样式未嵌入

这是我的风格

$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];;
它正在工作

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];

您在应该保留%@之后保留了它。您想将样式添加为属性还是作为开始和结束标记?我想在html的开头插入替换样式标记。它以正确的方式插入,但字体重量没有显示您可以共享您正在插入的css$1 p.p1{边距:0.0px 0.0px 0.0px 0.0px;字体:15.0px'Helvetica Neue'}span.s1{字体系列:'Helvetica Neue';字体重量:粗体;字体样式:正常;字体大小:15.00px;文本装饰:下划线}
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);