react-native - 如何更改nativebase中的活动页脚标签背景颜色
问题描述
我想在本机基础中更改活动页脚选项卡的背景颜色。我在官方文档中没有找到任何内容。请指导我。谢谢
<Footer style={styles.footer}>
<FooterTab style={styles.footerTab} >
<TouchableOpacity
onPress={() => this.props.navigation.navigate('Mainhome')}>
<Image
source={require('../assets/home.png')}
style={styles.footerIcon}
/>
</TouchableOpacity>
<TouchableOpacity
onPress={() => this.props.navigation.navigate('Search')}>
<Image
source={require('../assets/search.png')}
style={styles.footerIcon}
/>
</TouchableOpacity>
<TouchableOpacity
</FooterTab>
<Footer>
解决方案
在选项卡栏内,您可以使用您的组件并更改其颜色,您需要默认传递活动道具,活动颜色为蓝色......并且要更改它只需将颜色添加到 fotter 选项卡内的组件工作示例:https://小吃.expo.io/@msbot01/authentic-chips
import React, { Component } from 'react';
import { Text, View, StyleSheet, ScrollView, FlatList } from 'react-native';
import { Container, Header, Content, Footer, FooterTab, Button} from 'native-base';
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {
tabStatus1:true,
tabStatus2:false,
tabStatus3:false,
tabStatus4:false,
}
}
componentDidMount(){
}
checkTabSelected(tab){
switch(tab) {
case 1:
this.setState({
tabStatus1:true,
tabStatus2:false,
tabStatus3:false,
tabStatus4:false
})
// code block
break;
case 2:
this.setState({
tabStatus1:false,
tabStatus2:true,
tabStatus3:false,
tabStatus4:false
})
// code block
break;
case 3:
// code block
this.setState({
tabStatus1:false,
tabStatus2:false,
tabStatus3:true,
tabStatus4:false
})
break;
case 4:
this.setState({
tabStatus1:false,
tabStatus2:false,
tabStatus3:false,
tabStatus4:true
})
// code block
break;
}
}
render() {
return (
<View style={{ flex: 1 }}>
<Container>
<Header />
<Content />
<Footer>
<FooterTab>
<Button onPress={()=>{this.checkTabSelected(1)}} active={this.state.tabStatus1} style={{backgroundColor: this.state.tabStatus1?'red':null}} >
<Text>Apps</Text>
</Button>
<Button onPress={()=>{this.checkTabSelected(2)}} active={this.state.tabStatus2} style={{backgroundColor: this.state.tabStatus2?'red':null}}>
<Text>Camera</Text>
</Button>
<Button onPress={()=>{this.checkTabSelected(3)}} active={this.state.tabStatus3} style={{backgroundColor: this.state.tabStatus3?'red':null}}>
<Text>Navigate</Text>
</Button>
<Button onPress={()=>{this.checkTabSelected(4)}} active={this.state.tabStatus4} style={{backgroundColor: this.state.tabStatus4?'red':null}}>
<Text>Contact</Text>
</Button>
</FooterTab>
</Footer>
</Container>
</View>
);
}
}
const styles = StyleSheet.create({
});
推荐阅读
- apache-spark - 选择 distinct 在 Apache Spark DataFrame 中不起作用
- java - 在“初始化 Java 工具”期间发生内部错误。java.lang.NullPointerException
- ajax - 在 Codeigniter 中通过 ajax 获取数据
- c# - 如何在复选框列表的单个复选框上进行选择?
- java - 点击文件夹没有反应
- css - 相对内部的绝对定位 - 使用底部:0 似乎不起作用
- android - 如何解决这个 Android 请求关键字错误?
- c# - 在多个文件中解析 excel 文件时覆盖最后一个文件(C# windows 窗体)
- google-apps-script - 检查特定列是否包含活动单元格
- reverse-engineering - 如何从二进制可执行文件中删除恶意软件?