Icon标签栏文本颜色更改

问题描述 投票:0回答:1

如何在ui5应用程序中更改图标选项卡栏文本的颜色,我正在尝试更改文本图标选项卡栏的颜色。我有两个要根据条件更改的图标,我想更改第二个图标选项卡栏的文本颜色。我尝试了以下两种方法,但无法成功。以下是我的CSS,控制器和xml代码

   xml//

    <IconTabSeparator icon="sap-icon://open-command-field"/>
                    <IconTabFilter id="id"  icon="sap-icon://account"  design="Horizontal" 
    text="sales"
                        key="1" enabled="false"/>

    <IconTabFilter id="id2" icon="sap-icon://action" text="purchase" key="1"
                        enabled="false"/>


   css code//

   .TextColor{
   color: red !important;
   }

   controller//
    that.getView().byId("id").addStyleClass("TextColor");

    //getting error like below
    that.getView(...).byId(...).addStyleClass is not a function    

    that.getView().byId("id").getText().fontcolor("#ff3333").//no effect 
sapui5 sap-fiori
1个回答
0
投票

IconTabFilter使用iconColor属性更改颜色。

它可以使用有限数量的颜色选项-参见此处:options

我更喜欢使用模型绑定设置颜色:

控制器(根据需要调整条件):

if (condition == bad) that.getView().getModel("viewModel").setProperty("/salesIconColour", "Critical");

查看:

<IconTabFilter
        key="1"
        icon="sap-icon://account"
        iconColor="{viewModel>/salesIconColour}"
        text="sales"/>

您还可以直接在视图中使用内联绑定表达式(如果需要)。通过以上操作,您可以影响任何特定图标(销售或购买)的颜色。

© www.soinside.com 2019 - 2024. All rights reserved.