如何在 Nativescript HtmlView 标签中设置 link 颜色?
How do I set link color in Nativescript HtmlView tag?
我需要在 iOS 的 HtmlView 中更改 link 颜色。在 Android 上,我可以通过编辑 /app/App_Resources/Android/src/main/res/values/colors.xml
来设置默认颜色。我无法在 iOS 上找到如何做到这一点的方法。非常感谢任何帮助。
我已经尝试使用内联样式 {N} 属性,但似乎没有任何影响 link 的颜色。它适用于段落标记或跨度,但不会影响 links。
simplified/explaining代码
<HtmlView html="
<span>just some text </span>
<br>
<p style='text-align: center;'>
<span style='color: red;'>this will get colored </span>
<br>
<a href='https://google.com'>link - this will not get colored</a>
</p>
"></HtmlView>
图像在设备上的外观:
我无法在此处将其添加为图片...它需要 10+ 声望,而我没有。
提前感谢您的任何建议。
您可以调整原生对象上的 tintColor (iOS) / textColorLink (Android) .
HTML
<HtmlView @loaded="onLoaded" html="
<span>just some text </span>
<br>
<p style='text-align: center;'>
<span style='color: red;'>this will get colored </span>
<br>
<a href='https://google.com'>link - this will not get colored</a>
</p>
"></HtmlView>
方法
import * as colorModule from "tns-core-modules/color";
onLoaded: function(args) {
const color = new colorModule.Color("green");
if (args.object.ios) {
args.object.ios.tintColor = color.ios;
} else {
args.object.android.setLinkTextColor(color.android);
}
}
我需要在 iOS 的 HtmlView 中更改 link 颜色。在 Android 上,我可以通过编辑 /app/App_Resources/Android/src/main/res/values/colors.xml
来设置默认颜色。我无法在 iOS 上找到如何做到这一点的方法。非常感谢任何帮助。
我已经尝试使用内联样式 {N} 属性,但似乎没有任何影响 link 的颜色。它适用于段落标记或跨度,但不会影响 links。
simplified/explaining代码
<HtmlView html="
<span>just some text </span>
<br>
<p style='text-align: center;'>
<span style='color: red;'>this will get colored </span>
<br>
<a href='https://google.com'>link - this will not get colored</a>
</p>
"></HtmlView>
图像在设备上的外观:
我无法在此处将其添加为图片...它需要 10+ 声望,而我没有。
提前感谢您的任何建议。
您可以调整原生对象上的 tintColor (iOS) / textColorLink (Android) .
HTML
<HtmlView @loaded="onLoaded" html="
<span>just some text </span>
<br>
<p style='text-align: center;'>
<span style='color: red;'>this will get colored </span>
<br>
<a href='https://google.com'>link - this will not get colored</a>
</p>
"></HtmlView>
方法
import * as colorModule from "tns-core-modules/color";
onLoaded: function(args) {
const color = new colorModule.Color("green");
if (args.object.ios) {
args.object.ios.tintColor = color.ios;
} else {
args.object.android.setLinkTextColor(color.android);
}
}