使用适用于 Android 和 ios 的 Angular NativeScript 的透明选项卡栏和操作栏

2024-05-19

我想让标签栏透明,操作栏在滑动布局或页面上透明。操作栏或选项卡栏必须位于页面顶部,就像两层一样

我尝试过使用 css 使其透明,但它在页面上并没有变得透明。

<ActionBar title="Name" backgroundColor="#00000000"></ActionBar>

<TabView androidTabsPosition="bottom" selectedTabTextColor="white">
   <page-router-outlet
      *tabItem="{iconSource: getIconSource('test')}"
       name="homeTab">
    </page-router-outlet>

    <page-router-outlet
        *tabItem="{iconSource: getIconSource('test2')}"
        name="locationTab">
    </page-router-outlet>

    <page-router-outlet
        *tabItem="{iconSource: getIconSource('test3')}"
        name="searchTab">
    </page-router-outlet>
</TabView>

页面上的透明操作栏

Example https://i.stack.imgur.com/r15in.jpg


使用您选择的背景图像或颜色设置页面/根布局的样式

.page {
       background: url(https://cdn.pixabay.com/photo/2017/08/12/10/13/background-2633962__340.jpg);
       background-repeat: no-repeat;
       background-size: cover;
    }

Android

  • Set ActionBar's backgroundColor to transparent
  • Upon loaded事件调整Page要素单位制

    onLoaded(event: EventData) {
        const layout = <GridLayout>event.object,
           page = layout.page;
    
        if (page.android) {
           page.android.removeRowAt(0);
        }
    }
    
  • 调整根布局的内边距,使内容不会与 ActionBar 重叠

iOS

Adjust ActionBar属性基于loaded event

onActionBarLoaded(event: EventData) {
    const actionBar = <ActionBar>event.object;
    if (actionBar.ios) {
        (<any>actionBar).updateFlatness = function (navBar) {
            actionBar.ios.setBackgroundImageForBarMetrics(UIImage.new(), UIBarMetrics.Default);
            actionBar.ios.translucent = true;
        };
    }
}

(针对 v5.x 验证兼容性)

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用适用于 Android 和 ios 的 Angular NativeScript 的透明选项卡栏和操作栏 的相关文章

随机推荐