我正在尝试使用“反应导航”仅在 android 中更改标签栏的背景颜色。可能吗 ?
我使用下面的 tabBarOptions,但它会在 iOS 和 Android 中更改背景颜色,但我的要求是仅在 Android 中更改颜色,并且它应该在 iOS 中保持默认值,
{ tabBarOptions: { style: { backgroundColor: '#2D61A9', } } }
提前致谢。
我正在尝试使用“反应导航”仅在 android 中更改标签栏的背景颜色。可能吗 ?
我使用下面的 tabBarOptions,但它会在 iOS 和 Android 中更改背景颜色,但我的要求是仅在 Android 中更改颜色,并且它应该在 iOS 中保持默认值,
{ tabBarOptions: { style: { backgroundColor: '#2D61A9', } } }
提前致谢。
您可以使用Platform
see here设置平台操作系统特定的样式。
以下应该工作。
{
tabBarOptions : {
style: {
Platform.select({
android: {
backgroundColor: '#2D61A9',
},
}
}
}
使用平台进行简单的 ios 检查
import { Platform } from 'react-native';
const style = Platform.OS === 'ios' ? {} : {backgroundColor: '#2D61A9'}
{ tabBarOptions: { style } }