2016-08-01 45 views

回答

0

存儲你的動畫中的狀態變量,並調用startstop當你點擊一個按鈕:

constructor() { 
    super(props); 

    var my_animation = ... // define your animation here 

    this.state = { 
     my_animation: my_animation; 
    } 
} 

startAnimation() { 
    this.state.my_animation.start(); 
} 

stopAnimation() { 
    this.state.my_animation.stop(); 
} 

render() { 
    <Button onPress={() => this.startAnimation()} /> 
    <Button onPress={() => this.stopAnimation()} /> 
} 

欲瞭解更多信息有關startstop看到https://facebook.github.io/react-native/docs/animations.html

+0

很抱歉不能使問題清楚,其實我是想通過啓動按鈕A動畫和停止,但噸B –

+0

@GerardTaub看到更新 – FuzzyTree

+0

thx @FuzzyTree,在這裏提出了一個示例,但沒有按預期工作:( https://rnplay.org/apps/PozUMg –