首页 > 解决方案 > 如何在滚动时更改应用栏的背景颜色(REACT NATIVE)

问题描述

我想在滚动几次后将背景颜色设为白色......而且因为我的图标在滚动几次后也是白色的,所以我希望它是橙色或黑色......

我不太擅长解释,但我希望你能理解我想要达到的目标,我试图研究但一无所获......如果你能提供帮助,我将不胜感激......

 <Appbar.Header style={styles.appbar}>
            <Appbar.Action
              style={{paddingLeft: 5}}
              icon="wallet-outline"
              color="white"
              onPress={() => console.log('Pressed label')}
            />
            <View
              style={{
                flexDirection: 'row',
                alignItems: 'center',
                justifyContent: 'flex-start',
                minWidth: 223,
                marginHorizontal: 8,
                backgroundColor: 'white',
                borderRadius: 5,
              }}>
              <Appbar.Action
                style={{paddingLeft: 5}}
                icon="magnify"
                size={18}
                color="grey"
                onPress={() => console.log('Pressed label')}
              />
              <Text
                style={{
                  fontSize: 16,
                  color: 'grey',
                  paddingRight: 5,
                  color: '#FB502F',
                }}>
                Find Your Services
              </Text>
              <Appbar.Action
                icon="camera-outline"
                size={20}
                onPress={() => console.log('Pressed label')}
              />
            </View>
            <Appbar.Action
              icon="cart-outline"
              color="white"
              onPress={() => console.log('Pressed label')}
            />
            <Appbar.Action icon="message-text-outline" color="white" />
          </Appbar.Header>

我在想一个 if 和 else 语句......但我只是新手反应原生所以我不知道如何......

同样,我想在滚动后将透明 AppBar 的背景颜色更改为白色,并且我希望图标也更改颜色,因为如果我的 AppBar 将是白色的,那么图标将不会被看到,因为图标是白色的。 ..

提前致谢!!!如果您需要更多信息/详细信息,您可以编辑我的帖子或评论我应该添加的内容,以便您更轻松地帮助我

标签: javascriptcssreact-nativeappbar

解决方案


推荐阅读