一、現象
當某一頁面的頂部取消默認的原生導航欄,同時頂部的色塊和窗口的背景色(backgroundColor)設置不一樣時,下拉頁面會出現斷層,如圖:
1、默認顯示為:
2、下拉時:
二、解決 (在pages.json中設置)
1、設置窗口背景,添加"backgroundColor": "#4b7efe",如:
{
"path": "pages/dashboard/index",
"name": "dashboard",
"style": {
"backgroundColor": "#4b7efe",
"navigationStyle": "custom",
"app-plus": {
"titleView": false
},
"navigationBarTextStyle": "white"
}
}
效果如:
2、禁止下拉,添加 "bounce": "none" ,如
{
"path": "pages/dashboard/index",
"name": "dashboard",
"style": {
"backgroundColor": "#4b7efe",
"navigationStyle": "custom",
"app-plus": {
"titleView": false,
"bounce": "none"
},
"navigationBarTextStyle": "white"
}
}
三、總結:
在iOS中頁面下拉出現斷層現象會降低用戶的體驗性,同時上去也不夠美觀,因些,對於斷層的處理還是很有必要的。