React Native:iOS中的透明Stack Navigator不起作用 [英] React Native: Transparent Stack Navigator in iOS doesn't work

查看:297
本文介绍了React Native:iOS中的透明Stack Navigator不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用React Navigation中的Stack Navigator,并希望通过以下代码使其透明:

I use a Stack Navigator from React Navigation and want to make it transparent with the following code:

const MyStackNavigator = new StackNavigator({
  ScreenOne: { screen: ScreenOne },
},{
  cardStyle: {
    backgroundColor: "transparent",
  }
});

(另请参阅: https://snack.expo.io/@pob/stacknavigator问题)

Android中的结果很好,而iOS中的结果是黑色的Stack Navigator:

The result in Android is fine, while the result in iOS is a black Stack Navigator:

Android应用

The Android App

iOS应用

我怀疑Stack Navigator卡的背景也是透明的iOS,但是iOS Stack Navigator后面还有另一个黑色View.

I suspect, that the background of the Stack Navigator's card is also transparent iOS, but that there's another black View behind the iOS Stack Navigator.

推荐答案

有一种解决方法.请尝试此链接以获取演示 https://snack.expo.io/ryLBDw-1Q

There is a workaround for this. Please try this link for a demo https://snack.expo.io/ryLBDw-1Q

发生的变化是我正在堆栈上为此设置一个配置

What changed is that i am setting a config for this on the stack

transitionConfig: () => ({
  containerStyle: {
    backgroundColor: 'transparent',
  },
})

这里也提到了此问题-> https://github.com/react-navigation/react-navigation/issues/2713

This issue also mentioned here -> https://github.com/react-navigation/react-navigation/issues/2713

这篇关于React Native:iOS中的透明Stack Navigator不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆