当屏幕以 react-native 加载时,如何在 Button 上显示动画?
我想在 Button 上应用动画并在它加载到屏幕时显示它的效果。所以请帮助我。我如何在 react-native 中实现此功能。
我想在 Button 上应用动画并在它加载到屏幕时显示它的效果。所以请帮助我。我如何在 react-native 中实现此功能。
使用此微调按钮库并根据 api 响应更改您的标志。
使用react-native-animatable
andreact-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
<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>