1

我有两个场景,登录和主页,两者的背景颜色都设置为黑色。但是在过渡期间,当卸载和安装时,似乎还有另一个背景是白色的。

有没有办法弄清楚背景是什么并将颜色也改为黑色?

这是我的设置:

const RouterWithRedux = connect()(Router)
const store = configureStore()

    export default class App extends Component {
      render() {
        return (
          <Provider store={store}>
            <RouterWithRedux>
              <Scene key='root'>
                <Scene component={Login} initial={true} key='login' sceneStyle={{backgroundColor: 'black'}} title='Login'/>
                <Scene component={Home} direction='vertical' key='Home' sceneStyle={{backgroundColor: 'black'}} title='Home'/>
              </Scene>
            </RouterWithRedux>
          </Provider>
        )
      }
    }

以及带有白色显示的过渡图像,有点难以看到,但是如果您看到右上角的电池图标,则右侧和顶部的登录场景下降(如从登录到主页,登录在被卸载的过程所以是半透明的黑色):

在此处输入图像描述

4

1 回答 1

2

将函数传递给getSceneStyle返回样式或StyleSheet对象的函数。

// ..
const getSceneStyle = (/* NavigationSceneRendererProps */ props, computedProps) => {
  const style = {
    backgroundColor: 'black',
  };
  return style;
};
// ..
<RouterWithRedux getSceneStyle={getSceneStyle}>
// ..

不要执行以下操作,只需将 prop 直接传递给RouterWithReduxconnect就会将其传递给Router组件:

const RouterWithRedux = connect()(<Router sceneStyle={{backgroundColor: 'black'}}/>)
于 2016-09-22T00:57:37.853 回答