react-native NavigatorIOS 使用方法
2018-03-29 17:08
489 查看
import React, {Component} from 'react'; import { Platform, StyleSheet, Text, View, NavigatorIOS, TouchableOpacity } from 'react-native'; export default class App extends Component<Props> { render() { return ( <NavigatorIOS style={{flex: 1}} // 此项不设置,创建的导航控制器只能看见导航条而看不到界面 interactivePopGestureEnabled={true}//决定是否启用滑动返回手势。 translucent={true}//决定导航条是否半透明 initialRoute={{//初始化路由 component: Home,//路由的根视图 title: '首页',//标题 }} /> ); } } class Home extends Component { _onPressView(nextRoute) { this.props.navigator.push(nextRoute) } render() { const nextRoute = { component: Detail,//目的地视图 title: '详情',//目的地标题 titleTextColor: 'blue',//标题颜色 shadowHidden: true,//决定是否要隐藏1像素的阴影 barTintColor: 'white',//导航条的背景颜色 tintColor: 'orange', // 按钮的颜色 leftButtonTitle: '返回',//导航条的左按钮 onLeftButtonPress: () => { this.props.navigator.pop() }, rightButtonTitle: '相册',//导航条的右按钮 onRightButtonPress: () => {//导航条右按钮触发事件 alert('没有该照片'); }, passProps: {myProp: 'bar'} }; return ( <View style={styles.container}> <TouchableOpacity onPress={() => { this._onPressView(nextRoute) }} > <Text>{"详情!"}</Text> </TouchableOpacity> </View> ) } } class Detail extends Component { render() { return ( <View style={[styles.container, {backgroundColor: "green"}]}> <TouchableOpacity onPress={() => { this.props.navigator.pop() }} > <Text>{"首页!"}</Text> </TouchableOpacity> </View> ) } } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: 'red', } });
相关文章推荐
- react-native组件中NavigatorIOS和ListView结合使用的方法
- React Native之 Navigator与NavigatorIOS使用
- React Native中TabBarIOS的简单使用方法示例
- React-Native 之 Navigator与NavigatorIOS使用
- React Native中Navigator的使用方法示例
- React-Native Android 与 IOS App使用一份代码实现方法
- React Native知识6-NavigatorIOS组件
- (六)React Native---NavigatorIOS 组件
- React Native Sublime 中 Package Control 的安装与使用方法
- 【REACT NATIVE 系列教程之十一】插件的安装、使用与更新(示例:REACT-NATIVE-TAB-NAVIGATOR)
- ReactNative的Navigator组件使用方式
- [深入剖析React Native]热更新之react-native-pushy使用指南(IOS)
- 使用react-native-pull实现跨平台Android&IOS下拉刷新滑动回弹效果
- TabBar切换页的实现——React-native-tab-navigator的使用
- An iOS Developer on React Native一个资深iOS开发者对于React Native具体使用体验
- React-Native- RefreshControl && Navigator 使用案例
- React Native Android的启动白屏/闪屏的原因,解决方案,原理,使用方法
- RN(react native)入坑指南-07,使用navigator实现页面跳转
- ReactNative的Navigator组件使用方式
- 使用react-native-pull实现跨平台Android&IOS下拉刷新滑动回弹效果