提交 b078ce77 编写于 作者: DCloud-yinjiacheng's avatar DCloud-yinjiacheng

还原状态栏背景色相关示例代码

上级 d3dc740d
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
mounted() { mounted() {
uni.setNavigationBarColor({ uni.setNavigationBarColor({
frontColor: "#000000", frontColor: "#000000",
backgroundColor: "#007aff", backgroundColor: "#ffffff",
}); });
}, },
methods: { methods: {
......
...@@ -380,13 +380,6 @@ ...@@ -380,13 +380,6 @@
"navigationBarTitleText": "设置导航条颜色" "navigationBarTitleText": "设置导航条颜色"
} }
}, },
{
"path": "pages/API/set-navigation-bar-color/set-navigation-bar-color-custom-navigation",
"style": {
"navigationStyle": "custom",
"navigationBarTitleText": "设置状态栏颜色"
}
},
{ {
"path": "pages/API/set-navigation-bar-title/set-navigation-bar-title", "path": "pages/API/set-navigation-bar-title/set-navigation-bar-title",
"style": { "style": {
...@@ -1087,8 +1080,7 @@ ...@@ -1087,8 +1080,7 @@
{ {
"path": "pages/template/swiper-vertical-video/swiper-vertical-video", "path": "pages/template/swiper-vertical-video/swiper-vertical-video",
"style": { "style": {
"navigationStyle": "custom", "navigationStyle": "custom"
"navigationBarBackgroundColor": "transparent"
} }
}, },
// #ifdef APP // #ifdef APP
...@@ -1103,8 +1095,7 @@ ...@@ -1103,8 +1095,7 @@
"path": "pages/template/scroll-fold-nav/scroll-fold-nav", "path": "pages/template/scroll-fold-nav/scroll-fold-nav",
"style": { "style": {
"navigationStyle": "custom", "navigationStyle": "custom",
"navigationBarTextStyle": "black", "navigationBarTextStyle": "black"
"navigationBarBackgroundColor": "transparent"
} }
}, },
{ {
...@@ -1136,16 +1127,14 @@ ...@@ -1136,16 +1127,14 @@
{ {
"path": "pages/template/pull-zoom-image/pull-zoom-image", "path": "pages/template/pull-zoom-image/pull-zoom-image",
"style": { "style": {
"navigationStyle": "custom", "navigationStyle": "custom"
"navigationBarBackgroundColor": "transparent"
} }
}, },
{ {
"path": "pages/template/navbar-lite/navbar-lite", "path": "pages/template/navbar-lite/navbar-lite",
"style": { "style": {
"navigationBarTitleText": "自定义导航栏", "navigationBarTitleText": "自定义导航栏",
"navigationStyle": "custom", "navigationStyle": "custom"
"navigationBarBackgroundColor": "#007aff"
} }
}, },
{ {
...@@ -1187,16 +1176,14 @@ ...@@ -1187,16 +1176,14 @@
"path": "pages/webview-screenshot-comparison/webview-screenshot-comparison", "path": "pages/webview-screenshot-comparison/webview-screenshot-comparison",
"style": { "style": {
"navigationBarTitleText": "截图对比测试", "navigationBarTitleText": "截图对比测试",
"navigationStyle": "custom", "navigationStyle": "custom"
"navigationBarBackgroundColor": "transparent"
} }
}, },
{ {
"path": "pages/webview-screenshot/webview-screenshot", "path": "pages/webview-screenshot/webview-screenshot",
"style": { "style": {
"navigationBarTitleText": "webview 截图测试", "navigationBarTitleText": "webview 截图测试",
"navigationStyle": "custom", "navigationStyle": "custom"
"navigationBarBackgroundColor": "transparent"
} }
}, },
// #ifdef APP // #ifdef APP
......
const CURRENT_PAGE_PATH =
'/pages/API/set-navigation-bar-color/set-navigation-bar-color-custom-navigation'
describe('set statusBar color', () => {
if (process.env.uniTestPlatformInfo.startsWith('web')) {
it('dummyTest', async () => {
expect(1).toBe(1)
})
return
}
let page
const adbScreenShotArea = {
x: 880,
y: 0,
width: 60,
height: 60
};
if (process.env.uniTestPlatformInfo.startsWith('android 6')) {
adbScreenShotArea.x = 535
adbScreenShotArea.width = 90
adbScreenShotArea.height = 50
} else if (process.env.uniTestPlatformInfo.startsWith('android 12')) {
adbScreenShotArea.x = 1160
adbScreenShotArea.width = 70
adbScreenShotArea.height = 80
}
beforeAll(async () => {
page = await program.navigateTo(CURRENT_PAGE_PATH)
await page.waitFor(1000)
})
it("setNavigationBarColor1", async () => {
await page.callMethod("setNavigationBarColor1");
const image = await program.screenshot({
adb: true,
area: adbScreenShotArea
});
expect(image).toMatchImageSnapshot();
});
it("setNavigationBarColor2", async () => {
await page.callMethod("setNavigationBarColor2");
const image = await program.screenshot({
adb: true,
area: adbScreenShotArea
});
expect(image).toMatchImageSnapshot();
});
})
<template>
<page-head title="setNavigationBarColor"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<button @tap="setNavigationBarColor1" class="uni-btn">
设置状态栏背景绿色,文字白色
</button>
<button @tap="setNavigationBarColor2" class="uni-btn">
设置状态栏背景红色,文字黑色
</button>
</view>
</template>
<script>
export default {
methods: {
setNavigationBarColor1() {
uni.setNavigationBarColor({
frontColor: "#ffffff",
backgroundColor: "#00ff00",
success: () => {
console.log("setNavigationBarColor success");
},
fail: () => {
console.log("setNavigationBarColor fail");
},
complete: () => {
console.log("setNavigationBarColor complete");
},
});
},
setNavigationBarColor2() {
uni.setNavigationBarColor({
frontColor: "#000000",
backgroundColor: "#ff0000",
success: () => {
console.log("setNavigationBarColor success");
},
fail: () => {
console.log("setNavigationBarColor fail");
},
complete: () => {
console.log("setNavigationBarColor complete");
},
});
},
},
};
</script>
...@@ -7,16 +7,9 @@ ...@@ -7,16 +7,9 @@
<button @tap="setNavigationBarColor2" class="uni-btn"> <button @tap="setNavigationBarColor2" class="uni-btn">
设置导航条背景红色,标题黑色 设置导航条背景红色,标题黑色
</button> </button>
<!-- #ifdef WEB -->
<button @tap="goNavbarLite" class="uni-btn"> <button @tap="goNavbarLite" class="uni-btn">
跳转自定义导航栏页面 跳转自定义导航栏页面
</button> </button>
<!-- #endif -->
<!-- #ifdef APP -->
<button @tap="goCustomNavigation" class="uni-btn">
跳转设置状态栏页面
</button>
<!-- #endif -->
</view> </view>
</template> </template>
...@@ -73,11 +66,6 @@ ...@@ -73,11 +66,6 @@
uni.navigateTo({ uni.navigateTo({
url: '/pages/template/navbar-lite/navbar-lite' url: '/pages/template/navbar-lite/navbar-lite'
}) })
},
goCustomNavigation() {
uni.navigateTo({
url: '/pages/API/set-navigation-bar-color/set-navigation-bar-color-custom-navigation'
})
} }
}, },
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册