UTA DevHub
UI Development/Splash Screen Guide

Platform Implementation

Native setup and configuration for iOS and Android splash screens

Platform Implementation

Overview

Setting up splash screens requires platform-specific configuration for both iOS and Android. This guide provides detailed instructions for each platform, ensuring your splash screen displays correctly across all devices and OS versions.

Platform Differences

iOS and Android handle splash screens differently:

  • iOS: Uses Storyboard files for launch screens
  • Android: Uses drawable resources and themes (with special handling for Android 12+)

iOS Configuration

iOS uses Storyboard files for splash screens, which offers flexibility in layout and automatic handling of different device sizes.

Install Dependencies

After installing react-native-bootsplash, install iOS pods:

cd ios && pod install

Generate Assets

Use the CLI tool to generate iOS-specific assets:

npx react-native-bootsplash generate \
  --assets-path=assets/splash \
  --background-color="#FFFFFF" \
  --logo-width=100 \
  --flavor=main \
  path/to/your/logo.png

This creates the necessary image assets and Storyboard files.

Configure Xcode Project

  1. Open iOS project in Xcode (ios/YourProject.xcworkspace)
  2. Set Launch Screen File in project settings:
    • Select your project in the Project Navigator
    • Go to "General" tab > "App Icons and Launch Screen"
    • Set "Launch Screen File" to "BootSplash" (created by the generator)

Update Info.plist

Add or update these entries in ios/YourProject/Info.plist:

<key>UILaunchStoryboardName</key>
<string>BootSplash</string>
 
<!-- For dark mode support -->
<key>UIUserInterfaceStyle</key>
<string>Automatic</string>

Configure AppDelegate

Update ios/YourProject/AppDelegate.mm to show the splash screen:

#import "RNBootSplash.h"
 
- (BOOL)application:(UIApplication *)application 
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  // ... existing code ...
  
  // Initialize and show splash screen
  [RNBootSplash initWithStoryboard:@"BootSplash" rootView:self.window.rootViewController.view];
  
  return YES;
}

iOS Customization Options

Custom Storyboard Layout

You can customize the generated Storyboard for more complex layouts:

  1. Open BootSplash.storyboard in Xcode
  2. Add additional UI elements (labels, secondary images, etc.)
  3. Use Auto Layout constraints for proper positioning
  4. Test on different device sizes using the preview

Dark Mode Support

To support dark mode with different assets:

  1. Create separate image sets for light and dark appearances
  2. In Xcode, select your image asset
  3. In the Attributes Inspector, change "Appearances" to "Any, Dark"
  4. Add appropriate images for each appearance

iOS Troubleshooting

Issue: Black screen appears instead of splash screen

Solutions:

  • Ensure UILaunchStoryboardName is correctly set in Info.plist
  • Verify the Storyboard file is included in the build target
  • Check that image assets are properly linked
  • Clean build folder and rebuild: Product > Clean Build Folder

Android Configuration

Android splash screen implementation varies based on the Android version, with Android 12+ introducing a new SplashScreen API.

Generate Assets

Run the asset generator for Android:

npx react-native-bootsplash generate \
  --assets-path=assets/splash \
  --background-color="#FFFFFF" \
  --logo-width=100 \
  --flavor=main \
  path/to/your/logo.png

Update MainActivity

Modify android/app/src/main/java/.../MainActivity.java:

import com.zoontek.rnbootsplash.RNBootSplash;
import android.os.Bundle;
 
public class MainActivity extends ReactActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    RNBootSplash.init(this); // Initialize splash screen
    super.onCreate(null); // Pass null to fix white flash
  }
}

Configure styles.xml

Update android/app/src/main/res/values/styles.xml:

<resources>
  <!-- Base application theme -->
  <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
    <!-- Your app theme customizations -->
  </style>
  
  <!-- BootSplash theme -->
  <style name="BootTheme" parent="Theme.BootSplash">
    <item name="bootSplashBackground">@color/bootsplash_background</item>
    <item name="bootSplashLogo">@drawable/bootsplash_logo</item>
    <item name="postBootSplashTheme">@style/AppTheme</item>
  </style>
</resources>

Update AndroidManifest.xml

Apply the BootTheme to MainActivity:

<activity
  android:name=".MainActivity"
  android:label="@string/app_name"
  android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
  android:launchMode="singleTask"
  android:windowSoftInputMode="adjustResize"
  android:exported="true"
  android:theme="@style/BootTheme">
  <!-- ... intent filters ... -->
</activity>

Android 12+ Specific Configuration

Android 12 introduced a new SplashScreen API with specific requirements:

Android 12 Requirements

  • Splash screens are mandatory on Android 12+
  • The system enforces specific design constraints
  • Custom animations are limited compared to earlier versions

Additional Configuration for Android 12+

  1. Update styles.xml for Android 12+ (create values-v31/styles.xml):

    <resources>
      <style name="BootTheme" parent="Theme.BootSplash">
        <item name="android:windowSplashScreenBackground">@color/bootsplash_background</item>
        <item name="android:windowSplashScreenAnimatedIcon">@drawable/bootsplash_logo</item>
        <item name="android:windowSplashScreenAnimationDuration">200</item>
        <item name="postBootSplashTheme">@style/AppTheme</item>
      </style>
    </resources>
  2. Handle the splash screen duration:

    // In MainActivity.java
    @Override
    protected void onCreate(Bundle savedInstanceState) {
      // Keep splash screen visible while app loads
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
        getSplashScreen().setKeepOnScreenCondition(() -> true);
      }
      
      RNBootSplash.init(this);
      super.onCreate(null);
    }

Dark Mode Support for Android

To support dark mode on Android:

  1. Create dark mode colors (values-night/colors.xml):

    <resources>
      <color name="bootsplash_background">#121212</color>
    </resources>
  2. Provide dark mode drawable if needed:

    • Place dark mode logo in drawable-night-*dpi folders
    • Or use vector drawables with theme colors

Android Troubleshooting

Issue: White flash appears before splash screen

Solutions:

  • Ensure super.onCreate(null) passes null parameter
  • Set android:windowDisablePreview to true in theme
  • Check that theme is properly applied in AndroidManifest.xml
  • Verify background color matches your splash screen

Platform-Specific Best Practices

iOS Best Practices

  • (Do ✅) Use vector images (PDF) when possible for better scaling
  • (Do ✅) Test on all device sizes including iPad if supported
  • (Do ✅) Keep Storyboard simple to avoid loading delays
  • (Don't ❌) Include text in images - use Storyboard labels for localization
  • (Consider 🤔) Using SF Symbols for system-consistent icons

Android Best Practices

  • (Do ✅) Use vector drawables for logos when possible
  • (Do ✅) Test on Android 12+ devices for new API compliance
  • (Do ✅) Provide all density resources (mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi)
  • (Don't ❌) Use large bitmap images that could cause OOM errors
  • (Be Aware ❗) Of status bar handling - it may overlay your content

Testing Your Implementation

iOS Testing Checklist

  • Test on iPhone SE (smallest screen)
  • Test on iPhone Pro Max (largest screen)
  • Test on iPad (if supported)
  • Verify landscape orientation (if supported)
  • Check dark mode appearance
  • Verify no layout shifts during transition

Android Testing Checklist

  • Test on Android 8 (API 26)
  • Test on Android 12+ (API 31+)
  • Test on small screen devices
  • Test on tablets (if supported)
  • Verify dark mode appearance
  • Check different aspect ratios (16:9, 18:9, 19:9)

Summary

Platform-specific implementation requires attention to detail and thorough testing. Key takeaways:

  • iOS: Focus on Storyboard configuration and Auto Layout
  • Android: Handle version differences, especially Android 12+
  • Both: Support dark mode and test on various devices
  • Assets: Use appropriate formats and resolutions
  • Testing: Verify on real devices when possible

Next Steps