import React from 'react';
import {
Text,View,StyleSheet,TouchableOpacity,Animated
} from 'react-native';
export default class App extends React.Component{
UNSAFE_componentWillMount=()=>{
this.animatedWidth=new Animated.Value(50);
this.animatedHeight=new Animated.Value(100);
};
animatedBox=()=>{
Animated.timing(this.animatedWidth,{
toValue:200,
duration:1000
}).start();
Animated.timing(this.animatedHeight,{
toValue:500,
duration:1000
}).start();
};
render(){
const animatedStyle={
width:this.animatedWidth,
height:this.animatedHeight
};
return (
<TouchableOpacity
style={styles.container}
onPress={this.animatedBox}
>
<Animated.View style={[styles.box,animatedStyle]}/>
</TouchableOpacity>
)
}
}
const styles=StyleSheet.create({
container:{
justifyContent:'center',
alignItems:'center',
},
box:{
backgroundColor:'blue',
width:50,
height:100
}
});
react native 动画组件
最新推荐文章于 2024-06-12 09:31:34 发布
关键词由CSDN通过智能技术生成