0

Is there a goto way to handle the status bar on iOS? For my app, I just want everything to be below the status bar.. but it looks like the only way to do that is to go to every single component and add padding? I would guess theres a way to do it in xcode but I have no clue!

Thanks!

billybob2
  • 681
  • 1
  • 8
  • 17

1 Answers1

2

There is already a component in react-native for the StatusBar

You just need to add it as

<YourParentWrapper style={{flex: 1}}>
  <View style={{ height, backgroundColor }}>
        <StatusBar { ...props } />
    </View>
  // ... Your navigation or the child components
</YourParentWrapper>

where the height is

Platform.OS === 'ios' ? 20 : StatusBar.currentHeight

This will handle your components below the default status bar for all the devices

Pritish Vaidya
  • 21,561
  • 3
  • 58
  • 76