RN 踩坑:內容區域高度
Dimensions 獲取的是裝置螢幕解析度對應的寬高,包含了 status bar 以及其它 bar.
ios
ios 比較簡單,就一個 statusBar,iphoneX 是一類,其它的是一類,使用 paddingTop 可抵消 statusBar,專案使用 native-base 的 header,設定如下:
paddingTop: platform === "ios" ? (variables.isIphoneX ? 39 : 15) : 0 height: platform === "ios" ? (isIphoneX ? 88 : 64) : 56 複製程式碼
android
android 有三種 bar:Soft menu, Status bar, Smart bar,其中,Smart bar 為魅族特有。在使用內容區域高度時需要考慮以上三種 bar。當然,工具已經有人做好了:ofollow,noindex">github.com/Sunhat/reac…