首页 > 解决方案 > React-Native 中的 SharedElement 转换

问题描述

当我尝试在两个屏幕之间转换时遇到问题。我期待类似的例子,但我得到了非常不同的东西。所以我创建了简单的设计来测试它,但我不知道如何才能获得最终结果?我会上传视频。所以我只在我的主页和图像所在的详细信息页面中添加了两件事。

这是我主页中的 ShareELement

   <SharedElement id="iamge">
      <Image
      source={images.bannerBg}
      resizeMode="cover"
      style={{
      width: "100%",
      height: "100%",
      borderRadius: 20,
      }
     />
  </SharedElement>

这是我的详细信息页面中的 ShareELement

    <SharedElement id={"image"}>
     <Image
      source={images.bannerBg}
      resizeMode="cover"
      style={{
      width: "100%",
      height: "100%",
      }}
      />
  </SharedElement>

我也在我的详细信息页面中添加了这个

PlantDetail.sharedElements = (route, otherRoute, showing) => [
  { id: "image", animation: "fade-in" },
];

所以我的最终结果是

在此处输入图像描述

期望像

在此处输入图像描述

对不起,我的英语不好!

标签: javascriptreact-native

解决方案


推荐阅读