2016-08-01 41 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 –