我正在尝试使用钩子创建动画,但我的代码有问题。有谁能够帮我?我测试时没有出现错误,但图像没有出现。我正在尝试让图片在我的加载屏幕上旋转。
export default function SplashLoading() {
const [rotateValue, setRotateValue] = useState(new Animated.Value(0));
useEffect(() => {
StartImageRotate();
}, []);
function StartImageRotate() {
rotateValue.setValue(0);
Animated.timing(rotateValue, {
toValue: 1,
duration: 3000,
easing: Easing.linear,
}).start(() => StartImageRotate());
}
const RotateData = rotateValue.interpolate({
inputRange: [0, 1],
outputRange: ["0deg", "360deg"],
});
return (
<Container>
<Animated.Image
style={{
height: 230,
transform: [{ rotate: RotateData }],
width: 250,
}}
source={{ uri: "./gear.png" }}
/>
</Container>
);
}