import React, { Component } from 'react';
import {
AppRegistry,
Button,
View,
Animated,
StyleSheet
} from 'react-native';
export default class myreact extends Component {
constructor(props) {
super(props);
this.state = {
a:new Animated.Value(0),
b:new Animated.Value(0),
c:new Animated.Value(0),
d:new Animated.Value(0),
e:new Animated.Value(0)
}
};
render() {
return (
<View style={{flex:1}}>
<Animated.View style={styles.contianer}>
<Animated.Text style={[styles.text,{opacity: this.state.a}]}>鱼</Animated.Text>
<Animated.Text style={[styles.text,{opacity: this.state.b}]}>C</Animated.Text>
<Animated.Text style={[styles.text,{opacity: this.state.c}]}>工</Animated.Text>
<Animated.Text style={[styles.text,{opacity: this.state.d}]}>作</Animated.Text>
<Animated.Text style={[styles.text,{opacity: this.state.e}]}>室</Animated.Text>
</Animated.View>
<Button onPress={()=>{
this.setState({
a:this.state.a,b:this.state.b,
c:this.state.c,d:this.state.d,
e:this.state.e
})
Animated.sequence([
Animated.timing(this.state.a, {
toValue:1,
duration:1000
}),
Animated.timing(this.state.b, {
toValue:1,
duration:1000
}),
Animated.timing(this.state.c, {
toValue:1,
duration:1000
}),
Animated.timing(this.state.d, {
toValue:1,
duration:1000
}),
Animated.timing(this.state.e, {
toValue:1,
duration:1000
})
]).start();
}}
title="press me"
color="#841584"
/>
</View>
);
}
}
var styles=StyleSheet.create({
contianer:{
flex:1,backgroundColor: 'lightblue',
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center' ,
},
text:{
fontSize: 50,
color: 'green',
fontFamily: '微软雅黑'
}
})
AppRegistry.registerComponent('myreact', () => myreact);
这就是系列动画,效果图为: