RN 组件 Animated

RN 组件 Animated

可动画的视图包括View、Text、Image、createAnimatedComponent(自定义)

只会简单的,后面再更

 constructor(props) {
        super(props);
        this.state = {  //这是动画效果
            bounceValue: new Animated.Value(1)  //初始值
        };
    }
    componentDidMount() {
        // 动画结束
        Animated.timing(
            this.state.bounceValue,  
            { toValue: 1.2, duration: 1000 } //结束值
        ).start();
    }
···
    render() {
        return (
            <Animated.Image
                style={{
                    width: width,
                    height: height,
                    transform: [{ scale: this.state.bounceValue }] //绑定到样式属性
                }}
                source={splashImg}
            />
        );
    }

猜你喜欢

转载自blog.csdn.net/snow51/article/details/80583962