我正在尝试制作类似于这张图片的动画屏幕,但我没有正确完成。b 我想要我上传的这张照片。我不擅长动画,请帮助我改进我的代码。我被动画困住了。
这就是我尝试过的。
import React, { Component } from 'react'
import { View, Image, Animated, Easing } from 'react-native'
const backgroundImage = require("../../../assets/icons/post.jpeg")
export default class Splash extends Component {
constructor(props) {
super(props)
this.state = { spinAnim: new Animated.Value(0) }
}
componentDidMount() {
this.handleAnimation()
}
handleAnimation = () => {
console.log("rree")
Animated.timing(
this.state.spinAnim,
{
toValue: 1,
duration: 500,
easing: Easing.linear,
useNativeDriver: true
}
).start();
}
render() {
const spin = this.state.spinAnim.interpolate({
inputRange: [0, 1],
outputRange: ['0deg', '360deg']
});
return (
<View>
<View style={{ flex: 1 }}>
<Animated.Image
source={backgroundImage}
resizeMode='cover'
style={{
position: 'absolute',
left: 40,
top: 100,
height: 100,
width: 100,
transform: [
{ rotate: spin },
]
}}
/>
</View>
</View>
)
}
}