作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用 react-native-tab-view。那么如何仅将背景颜色设置为选定的选项卡?
这就是我所拥有的...
<TabView
navigationState={this.state}
renderScene={SceneMap({
first: FirstRoute,
second: SecondRoute,
third: ThirdRoute,
fourth: FourthRoute,
})}
onIndexChange={index => this.setState({ index })}
initialLayout={{ width: Dimensions.get('window').width, height: Dimensions.get('window').height }}
useNativeDriver = {true}
renderTabBar={(props) =>
<TabBar
{...props}
indicatorStyle={{ backgroundColor: 'white' }}
style={{backgroundColor: "black", height: 40}}
renderIcon={this.renderIcon}
indicatorStyle={{backgroundColor: "#555555"}}
/>
}
/>
最佳答案
这适用于文本样式更改。您的情况唯一的区别是,而不是更改 renderlabel
内的“文本”标签上的样式您必须更改“查看”标签的样式。
renderLabel={({ route }) => {
return (
<View> //THIS IS WHERE YOU PUT THE CONDITIONAL STYLING
<Text
style={
route.key === props.navigationState.routes[this.state.index].key
? styles.selectedTabTextStyle
: styles.label
}
>
{route.title}
</Text>
</View>
);
}}
关于react-native - 如何在react-native-tab-view中更改所选选项卡的背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51266810/
我正在尝试用 Swift 编写这段 JavaScript 代码:k_combinations 到目前为止,我在 Swift 中有这个: import Foundation import Cocoa e
我是一名优秀的程序员,十分优秀!