1

我需要在 iOS 上的 HtmlView 中更改链接颜色。在 Android 上,我可以通过编辑设置默认颜色/app/App_Resources/Android/src/main/res/values/colors.xml。我找不到如何在 iOS 上做到这一点的方法。任何帮助将不胜感激。

我曾尝试使用内联样式 {N} 属性,但似乎没有任何影响链接的颜色。它适用于段落标签或跨度,但它不影响链接。

简化/解释代码


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

图像它在设备上的外观:

IOS

安卓

我无法在此处将其添加为图像...它需要 10 多个我没有的声誉。

提前感谢您的任何建议。

4

1 回答 1

2

您可以在本机对象上调整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);
   }
}
于 2019-07-01T19:30:36.827 回答