How to find height of status bar in Android through React Native?

前端 未结 4 1685
刺人心
刺人心 2021-01-30 20:31

How can I find the height of the status bar on Android through React Native?

If I check the React.Dimensions height the value seems to include the status ba

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-30 20:52

    You don't need any plugins for this (anymore), just use StatusBar.currentHeight:

    import {StatusBar} from 'react-native';
    console.log('statusBarHeight: ', StatusBar.currentHeight);
    

    EDIT: Apparently this does seem to work on Android always, but on iOS, initially undefined is indeed returned :(

提交回复
热议问题