首页 > 解决方案 > 使用标签更改颜色文本

问题描述

Label使用Nativescript时如何更改菜单栏上的文本颜色。

我的代码:

        <StackLayout row="1" orientation="horizontal" backgroundColor="#eae8e8" class="foot">
            <Label width="25%" textAlignment="left" [nsRouterLink]="['/photos']">
                <FormattedString>
                    <Span text="Photos"></Span>
                </FormattedString>
            </Label>
   <Label width="25%" textAlignment="left" [nsRouterLink]="['/albums']">
                <FormattedString>
                    <Span text="Albums"></Span>
                </FormattedString>
            </Label>
         </StackLayout>

我想要这样图片当点击

标签: htmltypescriptxhtmlnativescript

解决方案


您可以color在 CSS 和直接 HTML 中使用属性来指定元素的颜色。例如:

zontal" backgroundColor="#eae8e8" class="foot">
            <Label width="25%" textAlignment="left" [nsRouterLink]="['/photos']">
                <FormattedString>
                    <Span color="blue" text="Photos"></Span>
                </FormattedString>
            </Label>
   <Label width="25%" textAlignment="left" [nsRouterLink]="['/albums']">
                <FormattedString>
                    <Span text="Albums"></Span>
                </FormattedString>
            </Label>
         </StackLayout>

这是游乐场演示:https ://play.nativescript.org/?template=play-ng&id=gMhuwo&v=2


推荐阅读