react-native-navigation叠加如何工作?

时间:2019-11-27 16:37:29

标签: react-native react-native-navigation

我尝试显示一个覆盖图:

  

Navigation.showOverlay({component:{name:'app.overlay'}})

但是叠加层会显示在新屏幕中...

为什么叠加层未显示在当前屏幕上?

// Register screens ...
Navigation.registerComponent('app.home', () => AppHome);
Navigation.registerComponent('app.overlay', () => TestOverlay);

// Set stack root
Navigation.setRoot({
    root: { 
      stack: { 
         children: [{ component: { name: 'app.home' } }] 
      } 
    },
});

// AppHome component
<SafeAreaView style={styles.container}>
  <Button 
    onPress={() => Navigation.showOverlay({ component: { name : 'app.overlay' } })} 
    label="Press me" 
  />
</SafeAreaView>

// Overlay
<View style={{ ...StyleSheet.absoluteFill, opacity: 0.5, backgroundColor: 'red' }}>
  <Text>Test overlay</Text>
</View>

0 个答案:

没有答案