React native 反应本机导航-滑动到下一屏幕
我有一个非常简单的本地导航配置React native 反应本机导航-滑动到下一屏幕,react-native,react-native-navigation,React Native,React Native Navigation,我有一个非常简单的本地导航配置 Navigation.startTabBasedApp({ tabs: [ { label: "One", screen: "example.FirstTabScreen", title: "Screen One" }, { label: "Two", screen: "example.SecondTabScreen", title: "Screen Two"
Navigation.startTabBasedApp({
tabs: [
{
label: "One",
screen: "example.FirstTabScreen",
title: "Screen One"
},
{
label: "Two",
screen: "example.SecondTabScreen",
title: "Screen Two"
}
]
}
我在文档中找不到任何用于从屏幕1切换到屏幕2的API。你知道这是否可能吗?我不知道react导航有滑动功能,但你可以使用任何其他滑动库 示例库:
在这个库中,您可以使用滑动功能,在滑动功能中,您可以导航到任何页面。现在有一个软件包可以执行您想要的操作
从中间页面开始,每刷3页(只需导入屏幕) 将此滑动作为屏幕导入导航中(您可以导航到 滑动或您可以导航到滑动下的任何屏幕)
这个图书馆为我工作。安装相当轻。而且实现很简单 您可以滑动或轻触菜单项在屏幕之间导航 文档似乎也很详细。这里列出了很多元素和参数。 对我来说唯一的一件事是,我花了一段时间才弄明白如何将定制添加到选项卡中。没有例子。 为了节省您一些时间(希望如此),下面是我的组件的外观。注意我是如何添加额外的东西来定制样式的
<TabView
navigationState={this.state}
renderScene={SceneMap({
first: App1,
second: App2,
third: App3
})}
onIndexChange={index => this.setState({ index })}
initialLayout={{ width: Dimensions.get('window').width }}
tabBarPosition="bottom"
renderTabBar={props =>
<TabBar
{...props}
indicatorStyle={{
backgroundColor: 'blue',
height:3 }}
style={{ backgroundColor: 'lightgrey' }}
renderLabel={({ route, focused, color }) => (
<Text style={{
fontSize: 18,
fontWeight: 'bold',
margin: 10 }}>
{route.title}
</Text>
)}
/>
}
// End of renderTabBar
/>
this.setState({index})}
initialLayout={{width:Dimensions.get('window').width}
tabBarPosition=“底部”
renderTabBar={props=>
(
{route.title}
)}
/>
}
//renderTabBar的结尾
/>
要通过滑动进行导航,您可以使用react导航2.x版本中引入的createMaterialTopTabNavigator
。它允许您通过点击路线或水平滑动在不同路线之间切换。
如果要使用滑块
或滑动选项卡
,可以使用以下选项:-
对于同一屏幕上的多个选项卡
:-
不,据我所知,您可以使用滑动手势(向上和向下)进行正常导航(使用动画从向上或向下滑动动画进行导航),但这不是滑动手势,而是滑动手势
<TabView
navigationState={this.state}
renderScene={SceneMap({
first: App1,
second: App2,
third: App3
})}
onIndexChange={index => this.setState({ index })}
initialLayout={{ width: Dimensions.get('window').width }}
tabBarPosition="bottom"
renderTabBar={props =>
<TabBar
{...props}
indicatorStyle={{
backgroundColor: 'blue',
height:3 }}
style={{ backgroundColor: 'lightgrey' }}
renderLabel={({ route, focused, color }) => (
<Text style={{
fontSize: 18,
fontWeight: 'bold',
margin: 10 }}>
{route.title}
</Text>
)}
/>
}
// End of renderTabBar
/>