使用react-router-flux为场景添加一个图标

时间:2016-11-29 14:42:04

标签: react-native react-router

使用react-router-flux为场景添加一个图标,我尝试使用leftButtonImage属性,但我无法将图像分配给按钮。 Something like this image

<Scene
  onLeft={() => Actions.Menu ()}
  leftButtonImage='https://facebook.github.io/react/img/logo_og.png'
  key="employeeList"
  component={Home}
  title="LOGO"
  initial
/>

2 个答案:

答案 0 :(得分:0)

根据documentation,您必须使用与<Image/>中的source prop相同的对象。您的代码应如下所示:

<Scene
  onLeft={() => Actions.Menu ()}
  leftButtonImage={{uri:'https://facebook.github.io/react/img/logo_og.png'}}
  key="employeeList"
  component={Home}
  title="LOGO"
  initial
/>

答案 1 :(得分:0)

使用react-native-router-flux中的Stack标签并使用icon属性

<Stack
      key="home"
      title= "My Title at nav bar"
      icon={() => <Icon size={24} name="home" /> 
      text="Home"
     >
      <Scene
            onLeft={() => Actions.Menu ()}
            leftButtonImage='https://facebook.github.io/react/img/logo_og.png'
            key="employeeList"
            component={Home}
            title="LOGO"
            initial
            />
    </Stack>