我正在构建HTML电子邮件,我知道这是一个已知问题,我已经尝试了许多解决方案来强制地址/电话/电子邮件文本不改变颜色并成为Gmail和ios上的链接。部分适用于我的唯一解决方案是将我的文本放在里面,使用标签和样式来获得我需要的字体颜色。这是我的榜样:
...<tr><td bgcolor="#F2F2F2" align="center" style="color:#3C3D3F;line-height:24px;font-family:Tahoma, Arial, Helvetica, sans-serif;padding:15px 10px;font-size:12px;"><a href="" style="outline:none;color:#3C3D3F;cursor:initial;text-decoration:none;"><span style="color:#3C3D3F;">128 Prinston St | Somewhere, CA 22314</span></a></td></tr>...
这就像我需要的字体颜色一样,但我不希望将此文本作为链接。现在我必须将href属性保留为空,当单击iOS默认电子邮件中的文本时,该属性将指向白页。
因此,请建议任何不需要在代码中添加标签的工作解决方案。
提前致谢。
答案 0 :(得分:0)
如何为链接添加通用样式。
<style> a:link { color: #3C3D3F; } </style>
代码:
NSString *styledHTML = [@"<style> a:link { color: #3C3D3F; } </style>" stringByAppendingString:originalHTMLString];
或
NSRange rOriginal = [originalHTMLString rangeOfString:@"<tr>"];
NSString *styledHTML = [originalHTMLString stringByReplacingCharactersInRange:rOriginal withString:@"<tr><style> a:link { color: #dc3535; } </style>"];
答案 1 :(得分:0)
如果您不想要蓝色下划线,数据检测器在制作电子邮件时会变得非常痛苦。我建议你尝试几种技术。
将以下内容放入电子邮件的<head></head>
部分。如果您已有<style></style>
部分,请将其添加到其中:
<style>
*[x-apple-data-detectors], .x-gmail-data-detectors, .x-gmail-data-detectors *, .aBn {
border-bottom: 0 !important;
cursor: default !important;
color: inherit !important;
text-decoration: none !important;
font-size: inherit !important;
font-family: inherit !important;
font-weight: inherit !important;
line-height: inherit !important;
}
</style>
如果这不能解决问题,你可以在下划线的区域周围做这样的事情:
<span style="color: inherit !important; text-decoration: none !important; ">your content here</span>
可能解决问题的一件事是将META标记添加到<head></head>
区域:
<meta name="format-detection" content="telephone=no" />
<meta name="format-detection" content="email=no" />
<meta name="x-apple-disable-message-reformatting" />
如果所有其他方法都失败了(我遇到了其他所有方法都失败的问题),我发现添加非打印字符可能有助于阻止数据检测器检测到网址,电话号码,地址或日期。
‌
这方面的变化通常是有效的:
gwally‌@‌stackoverflow‌.‌com
祝你看到丑陋的蓝线。