1-4项目底部导航菜单开发
来源:1-5 项目底部导航菜单开发
慕田峪1131113
2018-04-18
在底部导航菜单开发中,点击底部tabBar:1.页面没有任何改变;2.底部图片以及文字也没有相应的变色;3.页面初始化完成第一个页面的背景色没有添加进去
1回答
-
慕田峪1678153
2018-04-22
render() {
return (
<View style={styles.container}>
<TabNavigator>
<TabNavigator.Item
selected={this.state.selectedTab === 'tab_popular'}
selectedTitleColor={{color:'blue'}}
title="最热"
renderIcon={() => <Image style={styles.image} source={require('./res/images/ic_my.png')}/>}
renderSelectedIcon={() => <Image style={[styles.image, {tintColor:'blue'}]} source={require('./res/images/ic_my.png')}/>}
badgeText="1"
onPress={() => this.setState({selectedTab: 'tab_popular'})}>
<View style={styles.page1}></View>
</TabNavigator.Item>
<TabNavigator.Item
selected={this.state.selectedTab === 'tab_trending'}
selectedTitleColor={{color:'green'}}
title="最热"
renderIcon={() => <Image style={styles.image} source={require('./res/images/ic_favorite.png')}/>}
renderSelectedIcon={() => <Image style={[styles.image, {tintColor:'green'}]} source={require('./res/images/ic_favorite.png')}/>}
onPress={() => this.setState({selectedTab: 'tab_trending'})}>
<View style={styles.page2}></View>
</TabNavigator.Item>
<TabNavigator.Item
selected={this.state.selectedTab === 'tab_favorite'}
selectedTitleColor={{color:'blue'}}
title="收藏"
renderIcon={() => <Image style={styles.image} source={require('./res/images/ic_my.png')}/>}
renderSelectedIcon={() => <Image style={[styles.image, {tintColor:'blue'}]} source={require('./res/images/ic_my.png')}/>}
badgeText="1"
onPress={() => this.setState({selectedTab: 'tab_favorite'})}>
<View style={styles.page1}></View>
</TabNavigator.Item>
<TabNavigator.Item
selected={this.state.selectedTab === 'tab_my'}
selectedTitleColor={{color:'green'}}
title="我的"
renderIcon={() => <Image style={styles.image} source={require('./res/images/ic_favorite.png')}/>}
renderSelectedIcon={() => <Image style={[styles.image, {tintColor:'green'}]} source={require('./res/images/ic_favorite.png')}/>}
onPress={() => this.setState({selectedTab: 'tab_my'})}>
<View style={styles.page2}></View>
</TabNavigator.Item>
</TabNavigator>
</View>
);
}00
相似问题