css - 如何更改外部 React Native 模块的样式
问题描述
我是 React Native 的新手,我正在为 TabBar 使用这个存储库。
我可以改变一些风格吗?默认情况下,气泡背景是蓝色的,我想将其更改为其他颜色。
在backgroundColorindex.js
下node_modules/react-native-fluidbottomnavigation
定义为#4C53DD
.
我可以从使用 TabBar 的那一刻开始更改它吗?
这是我的导航栏:
这是我的代码App.js
:
<TabBar
onPress={tabIndex => {
console.log(tabIndex);
curTab = tabIndex;
}}
values={[
{
title: 'requests',
image: require('./assets/requests.png'),
tintColor: 'red',
},
{
title: 'requests',
image: require('./assets/requests.png'),
tintColor: 'blue',
},
{
title: 'events',
image: require('./assets/events.png'),
default: true,
tintColor: 'green',
},
{
title: 'members',
image: require('./assets/members.png'),
tintColor: 'orange',
},
{
title: 'account',
image: require('./assets/account.png'),
tintColor: 'yellow',
},
]}
/>
正如您在图片中看到的那样,此 tintColor 不会更改背景颜色。我希望那个蓝色圆圈是另一种颜色。
解决方案
有一个属性tintColor
可以用于这两个TabBar
和每个项目,如下所示:
import TabBar, { iconTypes } from "react-native-fluidbottomnavigation";
<TabBar
iconStyle={{ width: 50, height: 50 }}
// CHANGE TINT COLOR HERE ---------------
tintColor="red" // Change tint color here
// --------------------------------------
onPress={(tabIndex) => {
console.warn(tabIndex);
}}
isRtl={ true }
iconSize={25}
values={[
{ title: "Home", icon: "alarm", tintColor: curTab == 0 ? "red" : "blue", default: true, isIcon: true, iconType: iconTypes.MaterialIcons },
{ title: "Home1", tintColor: curTab == 1 ? "red" : "blue", },
{ title: "Home2", tintColor: curTab == 2 ? "red" : "blue", },
{ title: "Home3", tintColor: curTab == 3 ? "red" : "blue", },
{ title: "Home4", tintColor: curTab == 4 ? "red" : "blue", },
]}
/>
如果您更仔细地阅读我的回答和 repo 中的 README,那么您会发现它tintColor
不仅适用于选项卡项,还适用于TabBar
组件本身。所以,如果你设置<TabBat tintColor="red" ...
你会像这样为气泡设置红色:
推荐阅读
- java - 调用使用 CompletableFuture 的 thenAccept() 的方法
- php - 如何解决此 Codeigniter-4 登录控制器问题?
- javascript - 我应该在哪里调用一个方法来使用它的数据?
- java - HIVE:异常:无法在 Mac 上使用 JDK8 将类 jdk.internal.loader.ClassLoaders$AppClassLoader 强制转换为类 java.net.URLClassLoader
- java - JAVA_HOME 路径更新为版本 11,cmd 中的 java 版本仍然显示 8
- swift - Firebase - iOS 应用程序在首次安装时卡在启动屏幕上
- java - 在 JSP 中打印列表对象
- go - 使用功能选项而不是方法
- amazon-web-services - AWS Cloudformation:如何使用用户名作为标签
- html - SwiftUI:VStack 中视图之间的重叠