RN:0.75
iOS: 最小的更改iOS使用LaunchScreen 把图片放入到里面
Android:把图片放入到 res/drawable/xxxpng
yarn add react-native-bootsplash
cd ios
pod install
iOS 配置
AppDelegate.mm 添加这两段,然后LaunchScreen配置启动页面就可以了
#import "RNBootSplash.h"
- (void)customizeRootView:(RCTRootView *)rootView { [super customizeRootView:rootView]; [RNBootSplash initWithStoryboard:@"LaunchScreen" rootView:rootView];
}
android:
MainActivity.kt
import com.zoontek.rnbootsplash.RNBootSplash
import android.os.Bundle
class MainActivity : ReactActivity() {
override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) RNBootSplash.init(this, R.style.BootTheme) }
启动图添加的到res/drawable里面定义xxx.png
添加在 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:windowIsTranslucent">true</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
<style name="BootTheme" parent="Theme.BootSplash.EdgeToEdge">
<item name="android:windowBackground">@drawable/xxx</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
</resources>