【发布时间】:2019-08-15 18:25:32
【问题描述】:
我正在学习 React Native,我想制作心跳动画
我这样做了,但结果不是很好,我想要心跳。
如果有人可以帮助我,那就太好了,非常感谢
import React, { PureComponent } from "react";
import { Animated, StyleSheet, Text, View } from "react-native";
export class Loading extends PureComponent {
constructor(props: any) {
super(props);
this.state = {
opacity: new Animated.Value(0),
};
}
public componentDidMount() {
Animated.timing(
this.state.opacity,
{
toValue: 100,
duration: 5000,
},
).start();
}
public render() {
return (
<View>
<View>
<Animated.View
style={[styles.animation, {
opacity: this.state.opacity,
transform: [
{
scale: this.state.opacity.interpolate({
inputRange: [0.5, 1],
outputRange: [1, 0.95],
}),
}]},
]}
/>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
animation: {
backgroundColor: "red,
width: 100,
height: 100,
borderRadius: 50,
},
});
【问题讨论】:
-
你尝试过lottiefiles动画吗..那些动画非常专业且易于使用
-
感谢您的回答,但我真的不希望我只需要动画