react-navigation 去除導航陰影

react-navigation 在某些界面不需要導航陰影

查找源碼 header.js

496 行

let platformContainerStyles;
if (Platform.OS === 'ios') {
  platformContainerStyles = {
    borderBottomWidth: StyleSheet.hairlineWidth,
    borderBottomColor: '#A7A7AA',
  };
} else {
  platformContainerStyles = {
    shadowColor: 'black',
    shadowOpacity: 0.1,
    shadowRadius: StyleSheet.hairlineWidth,
    shadowOffset: {
      height: StyleSheet.hairlineWidth,
    },
    elevation: 4,
  };
}

可以看到:

iOS 和 安卓實現的原理是不一樣的

iOS 是通過設置 borderBottomWidth borderBottomColor 來實現的 可以看出iOS 中將 borderBottomWidth 設置爲 0 即可

安卓是通過陰影來實現的 可以看出安卓中 設置 shadowOpacity 爲 0 即可獲贈 elevation: 0 可也以

所以在 headerStyle 中按照如上設置即可

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章