react-native配置启动屏和图标

76 阅读1分钟

本文没有使用三方插件,属于比较简单的启动屏配置

android

1.1 在android/app/src/main/res/values/styles.xml中配置

<resources>

   <!-- Base application theme. -->
   <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
       <!-- Customize your theme here. -->
       <item name="android:editTextBackground">@drawable/rn_edit_text_material</item>
       // 增加这行代码
       <item name="android:windowBackground">@drawable/bootsplash_logo</item>
   </style>

</resources>

1.2 增加文件夹和图片

image.png

ios

2.1 使用LaunchScreen.storyboard

  1. 在Xcode中打开ios/YourProject.xcworkspace
  2. 在项目导航器中找到LaunchScreen.storyboard
  3. 添加Image View并设置你的启动图片

image.png

image.png

2.2 或者使用静态图片资源

  1. 将启动图片添加到Images.xcassets中的LaunchImage
  2. 确保包含所有必要的尺寸(1x, 2x, 3x)