react native Animated简单使用方法

时间:2022-09-04 10:02:31
import { 
  Animated,
} from 'react-native';

constructor(props){
        super(props)
        this.state={ 
          fadeInOpacity: new Animated.Value(0), // 初始值 
        }
  }
componentDidMount(){ 
  Animated.timing(this.state.fadeInOpacity, {
      toValue: 1, // 目标值
    }).start();
  }
render(){
  return(
  <Animated.View style={{
     opacity: this.state.fadeInOpacity,justifyContent:'center',alignItems:'center',
                      backgroundColor:"#333",width:common.deviceWidth,height:common.deviceWidth*0.055}}>
                  <Text style={{color:"white"}}>123</Text>
    </Animated.View>
  )  
}