ActionBar

This is an overview of the most common usage of ActionBar. For more information about the available properties, methods, or events, head over to the complete API documentation for ActionBar.

ActionBar组件是Android ActionBar和iOS NavigationBar的NativeScript抽象。


使用标题

<ActionBar title="MyApp" />

使用自定义标题视图

<ActionBar>
  <StackLayout orientation="horizontal">
    <Image src="res://icon" width="40" height="40" verticalAlignment="center" />
    <Label text="NativeScript" fontSize="24" verticalAlignment="center" />
  </StackLayout>
</ActionBar>

为Android设置应用程序图标

<ActionBar title="My App" android.icon="res://icon" android.iconVisibility="always" />

删除边框

在iOS和Android上,在ActionBar的底部绘制了一个小边框。此外,iOS上ActionBar的背景颜色与您指定的略有不同,因为iOS应用了过滤器。要删除此过滤器和边框,请设置 flattrue

<ActionBar title="My App" flat="true" />

道具

名称类型描述
titleString要在ActionBar中显示的标题。
android.iconStringAndroid上显示的图标。
android.iconVisibilityString设置图标可见时的设置。
flatboolean删除边框和iOS颜色过滤器。默认 false
Contributors