【问题标题】:React-Native hide navbar when scrolling滚动时React-Native隐藏导航栏
【发布时间】:2017-02-23 09:49:19
【问题描述】:

我正在使用 react-native-navigation-flux 导航库, 我正在尝试实现导航栏在向下滚动时会消失。 有可能实现吗?

谢谢

【问题讨论】:

  • 欢迎来到 StackOverflow!请提供您尝试的Minimal, Complete, and Verifiable example,以便我们可以尝试解决您的问题并解释您自己的尝试失败的原因——这样您就可以学到对您未来发展有用的东西,并得到这个问题的答案。

标签: scroll react-native navbar


【解决方案1】:

尝试使用动画并将导航栏的高度设置为向上滚动时为零,向下滚动时设置默认高度。

 class MyAwesomeComponent extends Component {

   constructor(props) {
     super(props);
     this.height = new Animated.Value(100);
   }

   _setAnimation(enable) {
     Animated.timing(this.height, {
       duration: 400,
       toValue: enable? 100 : 0
     }).start()
   } 

   render() {
     return (
       <Animated.View style={{ height: this.height }}/>
     );
  }

}

【讨论】:

    猜你喜欢
    • 2017-03-03
    • 1970-01-01
    • 2019-01-07
    • 1970-01-01
    • 1970-01-01
    • 2021-02-07
    • 1970-01-01
    • 1970-01-01
    • 2021-03-12
    相关资源
    最近更新 更多