变化场景背景色反应本地路由器通量
问题描述:
这是我在我的router.js文件中的代码(从react-native-router-flux文档部分采取):变化场景背景色反应本地路由器通量
import React, { Component } from 'react';
import { Router, Scene } from 'react-native-router-flux';
import PageOne from './PageOne';
import PageTwo from './PageTwo';
export default class App extends Component {
render() {
return (
<Router>
<Scene key="root">
<Scene key="pageOne" component={PageOne} title="PageOne" initial={true} />
<Scene key="pageTwo" component={PageTwo} title="PageTwo" />
</Scene>
</Router>
)
}
}
我如何更改“标题”的背景颜色(上图中出现“返回”箭头)?
我想这种方式(增加sceneStyle={{ backgroundColor: 'red'}}
):
<Scene key="pageTwo" component={PageTwo} title="PageTwo" sceneStyle={{ backgroundColor: 'red'}} />
,但它似乎没有工作。
FYI:
"react-native": "0.34.1",
"react-native-router-flux": "^3.35.0"
答
正如库API docs描述,你必须为了改变标题样式使用navigationBarStyle财产。
试试这个:
<Scene key="pageTwo" component={PageTwo} title="PageTwo" navigationBarStyle={{ backgroundColor: 'red'}} />
谢谢你,但我只是发现了这里的解决方案:https://github.com/aksonov/react-native-router-flux/issues/160。 – splunk