ReactNative-NavigatorIOS用法
NavigatorIOS包装了UIKit的导航功能,可以使用左划功能来返回到上一界面。
路由
一个路由是用于描述导航器中一页的对象。NavigatorIOS的第一个路由通过initialRoute属性来提供。
render: function() {
return (
<NavigatorIOS
initialRoute={{
component: MyView,
title: 'My View Title',
passProps: { myProp: 'foo' },
}}
/>
);
},
导航器
导航器是一个object,包含了一系列导航函数,可供视图调用。它会作为props传递给NavigatorIOS渲染的任何组件。
var MyView = React.createClass({
_handleBackButtonPress: function() {
this.props.navigator.pop();
},
_handleNextButtonPress: function() {
this.props.navigator.push(nextRoute);
},
...
});
样例
// 添加导航栏
_addNavigator: function(component, title) {
return <NavigatorIOS
style = {{flex: 1}}
barTintColor = '#007aFF'
titleTextColor = "#fff"
tintColor = "#fff"
translucent = {false}
initialRoute = {{
component: component,
title: title,
passProps: {}
}}
/>;
}
通过调用此方法来创建每一个导航栏。
*是该烨烨生辉的年纪,我不敢停歇*

浙公网安备 33010602011771号