简体   繁体   English

Expo 矢量图标 - 如何更改背景颜色?

[英]Expo Vector Icon - how to change background color?

I am using Expo vector Icon in my app with React Native.我在我的应用程序中使用Expo 矢量图标和 React Native。 I'm using icons as below and it works fine for all the props.我正在使用如下图标,它适用于所有道具。 However, I've been trying to change the background color and it doesn't change as expected.但是,我一直在尝试更改背景颜色,但并没有按预期更改。 I've checked the docs and all the properties work as expected except for backgroundColor .我检查了文档,所有属性都按预期工作,除了backgroundColor Any idea why it isn't working?知道为什么它不起作用吗?

 <AntDesign
       name={name}
       size={size}
       color={color}
       iconStyle={iconStyle}
       backgroundColor="red"/>

The vector icon itself doesn't support the background property.矢量图标本身不支持背景属性。

You are referring to the Button, if you want to use the Button you will have to do like below您指的是按钮,如果您想使用按钮,您必须执行以下操作

 <AntDesign.Button
       name={name}
       size={size}
       color={color}
       iconStyle={iconStyle}
       backgroundColor="red"/>

But if your requirement is only icon, you can simply style it但是如果您的要求只是图标,您可以简单地设置它

<AntDesign
       name={name}
       size={size}
       color={color}
       style={{backgroundColor:'red'}}/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM