当屏幕以本机模式加载时,如何在Button上显示动画?

问题描述 投票:3回答:4

当屏幕以本机模式加载时,如何在Button上显示动画?

我想在Button上应用动画并在加载到screen时显示它的效果。所以请帮助我。我如何在react-native中实现此功能。

react-native react-native-android react-native-ios react-native-animatable
4个回答
2
投票

使用此spinner button库并根据api响应更改您的标志。


1
投票

使用react-native-animatablereact-native-button可以在按钮上实现动画,简单表达之一如下

<View style={styles.container}>
     <Button onPress={this.onPress}>
          <Animatable.Text 
               animation="pulse"
               easing="ease-out" 
               iterationCount="infinite" 
               style={{ textAlign: 'center', fontSize: 100 }}>
                  OK
         </Animatable.Text>
      </Button>
 </View>

您可以设置isLoading的状态,并在加载完成时将迭代计数设置为0


1
投票
<View style={styles.container}>
     <Button onPress={this.onPress}>
{this.state.isLoading ? 
<React.Fragment>
          <Text style={{ textAlign: 'center', fontSize: 100 }}>
                  Loading ...
         </Text>


<ActivityIndicator/>

</React.Fragment> : <Text>Press me <Text>
      </Button>
 </View>

0
投票

您可以使用这一解决方案来实现您的功能。

https://github.com/rcaferati/react-native-really-awesome-button

© www.soinside.com 2019 - 2024. All rights reserved.