[英]React Native CLI - How to properly manage the bottom Android navigation bar color? White in light mode / Dark in dark mode?
Here's an image of what I'm referring to, the android emulator is on the left.这是我所指的图像,android 仿真器在左侧。 I can switch my app between light / dark and the components change color on demand but I'm not sure how to approach this bottom navigation bar.
我可以在浅色/深色之间切换我的应用程序,并且组件会根据需要更改颜色,但我不确定如何处理这个底部导航栏。 Thank you in advance for any tips on this.
提前感谢您对此的任何提示。
The solution was a lot easier than I thought.解决方案比我想象的要容易得多。 If you're using React Navigation you can use the screen options prop to define the navigation bar color.
如果你使用 React Navigation,你可以使用 screen options 属性来定义导航栏的颜色。 Here is an example:
这是一个例子:
export function AuthStackNavigator() {
const isDarkMode = useColorScheme() === 'dark';
return (
<Stack.Navigator
screenOptions={{ navigationBarColor: isDarkMode ? theme.colors.black : theme.colors.white }}>
<Stack.Screen name="Landing" component={LandingScreen} options={{ headerShown: false }} />
</Stack.Navigator>
);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.