[英]How to play an intro animation on splash screen with react native expo?
Currently, if I add a .gif to app.json, it does not work 目前,如果我向app.json添加.gif文件,它将无效
"splash": {
"image": "./assets/splash.gif"
}
Edit: It looks like, they are currently working on it, here: ( https://expo.canny.io/feature-requests/p/improved-splash-screen-api ). 编辑:看起来,他们正在研究它,在这里:( https://expo.canny.io/feature-requests/p/improved-splash-screen-api )。
I see you are trying to use gif for the splash screen. 我看到你正在尝试使用gif作为启动画面。 Well I have a bad news.
好吧,我有一个坏消息。 Splash screen API of native platform (iOS & Android) doesn't support gif, infact they only support 'png' images.
原生平台(iOS和Android)的启动画面API不支持gif,实际上它们只支持'png'图像。
But, the good news is there is a work around. 但是,好消息是有一个解决方法。
We had a similar requirement in our project so we created our custom AppLoading (Provided by Expo) component which has a face of our gif image and in the background it works similar to AppLoading ie fetch data and caching. 我们在项目中有类似的要求,所以我们创建了我们的自定义AppLoading(由Expo提供)组件,它具有我们的gif图像的面,在后台它的工作方式类似于AppLoading,即获取数据和缓存。 We used a static png image for default splash screen and the transition between static image to gif worked for us.
我们使用静态png图像作为默认的启动画面,静态图像到gif之间的转换为我们工作。
This is the simplest way but has a drawback that between the static splash screen and animated there is white screen visible for a short duration of time. 这是最简单的方法,但有一个缺点,即在静态闪屏和动画之间有短时间可见的白色屏幕。 It happens due to the fact that your javascript bundle is being downloaded in the background and until and unless your entire JS doesn't load you will see a white screen.
这是因为您的javascript包正在后台下载,直到除非您的整个JS没有加载,否则您将看到一个白色屏幕。
If you're talking about the launch screen and you're not using create-react-native-app
you'll have to edit the native launch screen per platform to use your animation. 如果您正在谈论启动屏幕并且您没有使用
create-react-native-app
,则必须编辑每个平台的本机启动屏幕以使用您的动画。
If you're using create-react-native-app
with Expo then you could look at the Splash Screen API . 如果您在Expo中使用
create-react-native-app
,那么您可以查看Splash Screen API 。
Expo since version 29 supports animated SVG and GIF. 自版本29以来的世博会支持动画SVG和GIF。 It also provides an API to generate your own splash screens without
AppLoading
. 它还提供了一个API,可以在没有
AppLoading
情况下生成您自己的启动画面。
Please check: https://docs.expo.io/versions/v29.0.0/sdk/splash-screen#example-without-apploading 请检查: https : //docs.expo.io/versions/v29.0.0/sdk/splash-screen#example-without-apploading
Expo team has completed: "Improved Splash Screen API" ticket. 世博团队已完成:“改进的Splash Screen API”门票。 So now, you can do it as explained in their docs: https://docs.expo.io/versions/v29.0.0/sdk/splash-screen/ !
所以现在,您可以按照他们的文档中所述进行操作: https : //docs.expo.io/versions/v29.0.0/sdk/splash-screen/ !
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.