简体   繁体   English

改变图标颜色的方法是什么

[英]What is the way to change the color of the icon

What is the way to change the color of the icon to red if the condition is greater than 0 and if it is equal to zero then it will be gray如果条件大于0,如果等于0,则将图标的颜色更改为灰色的方法是什么?

<TouchableOpacity
            onPress={() => {
              if (Object.values(selectedItems).length > 0)
                navigation.navigate('total', {
                  selectedItems: Object.values(selectedItems),
                });
            }}
          >
            <Icon size={40} color="white" name="barrel" />
          </TouchableOpacity>
<Icon size={40} color={condition ? "red" : "gray"} name="barrel" />

should work应该管用

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

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