react-native-bootsplash 手动接入

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>

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容