Bad*_*der 5 javascript reactjs react-native navigator-ios
向下滚动时,我试图隐藏导航栏(NavigatorIOS)。我怎样才能做到这一点?
谢谢
感谢@Vincent,我成功地在 React Native 中制作了与 AMScrollingnavbar 类似的简单代码。(PS:它有一个小故障,但我对整体结果感到满意)
import React, { Component } from 'react';
import { Text, View, ScrollView, Animated } from 'react-native';
import NavigationBar from 'react-native-navbar';
const AnimatedNavigationBar = Animated.createAnimatedComponent(NavigationBar);
export default class BasicListView extends Component {
state = { isNavBarHidden: false, height: new Animated.Value(64) };
setAnimation(disable) {
Animated.timing(this.state.height, {
duration: 100,
toValue: disable ? 0 : 64
}).start()
};
handleScroll(event) {
this.setAnimation((event.nativeEvent.contentOffset.y > 64));
this.setState({ isNavBarHidden: !this.state.isNavBarHidden });
}
render() {
return (
<View style={{ flex: 1 }} >
<AnimatedNavigationBar style={{ backgroundColor: 'red', height: this.state.height }} />
<ScrollView scrollEventThrottle={16} onScroll={this.handleScroll.bind(this)}>
<View style={{ height: 200 }}><Text>Test</Text></View>
<View style={{ height: 200 }}><Text>Test</Text></View>
<View style={{ height: 200 }}><Text>Test</Text></View>
<View style={{ height: 200 }}><Text>Test</Text></View>
<View style={{ height: 200 }}><Text>Test</Text></View>
</ScrollView>
</View>
);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12997 次 |
| 最近记录: |