Search code examples
react-nativesafeareaview

How change background color in React Native when NOT using SafeAreaView?


How can I change the color of the “iPhone app switcher” bottom bar here:

app switcher bar

I want to build a fullscreen app so I’m not using SafeAreaView.

This is my main screen/layout component:

const Screen = (props: any): React.ReactElement => {
  const { backgroundColor = 'white' } = props
  return (
    <>
      <View
        style={[styles.container, { backgroundColor }]}
      >
        <StatusBar
          backgroundColor={backgroundColor === 'black' ? 'black' : 'white'}
          barStyle={backgroundColor === 'black' ? 'light-content' : 'dark-content'}
        />
        {props.children}
      </View>
    </>
  )
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center'
  }
})

Solution

  • just need to change the tab bar backgroundColor like this

     <MainTab.Navigator
          screenOptions={{
            tabBarStyle:{
              backgroundColor:"black" //like this
            }
          }}>
    
      {...MaintabScreens}
    
    </MainTab.Navigator>