[英]React Native - Vector icons in Navigation bar
In my React Native app, I would like to use Vector Icons as navigation bar buttons. 在我的React Native应用中,我想使用Vector Icons作为导航栏按钮。 For that, I'm using: https://github.com/oblador/react-native-vector-icons For navigation: https://reactnavigation.org/
为此,我正在使用: https : //github.com/oblador/react-native-vector-icons导航: https : //reactnavigation.org/
I managed to set the icons as well, but when I tap the buttons, I get an unwanted effect where the background turns black. 我也设法设置了图标,但是当我点击按钮时,背景变成黑色,我得到了不想要的效果。 Is there a way how I can keep the background color transparent also when the button's pressed?
有没有办法在按下按钮时也能保持背景色透明?
Here's my code: 这是我的代码:
static navigationOptions = ({ navigation }) => {
const { params } = navigation.state
return {
headerTitle: "Blog posts",
headerRight: (
<Icon.Button name="quote-right" backgroundColor="transparent" color="black" onPress={() => params.postComment()}>
<Text style={{fontSize: 15}}></Text>
</Icon.Button>
),
headerLeft: (
<Icon.Button name="navicon" backgroundColor="transparent" color="black" onPress={() => params.postComment()}>
<Text style={{fontSize: 15}}></Text>
</Icon.Button>
),
};
};
And here's what I got: 这就是我得到的:
The prop you are looking for is underlayColor
, that's the one you should set to transparent
. 您要寻找的道具是
underlayColor
,这是您应该设置为transparent
的道具。
<Icon.Button
name="quote-right"
backgroundColor="transparent"
underlayColor="transparent" // This one
color="black"
onPress={() => params.postComment()}
>
<Text style={{fontSize: 15}}></Text>
</Icon.Button>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.