react-native-dynamic-splash
以中文查看
React Native dynamic launch page (advertisement page), support for Android and iOS
Installation
npm install react-native-dynamic-splash --save
Demo
IOS | Android |
---|---|
![]() |
![]() |
Rn installation
Android
Automatic installation
react-native link react-native-dynamic-splash
Manual installation
- android/settings.gradle File add code
include ':react-native-dynamic-splash'.projectDir = new File(rootProject.projectDir, '../node_modules/react-native-dynamic-splash/android')
- android/app/build.gradle File add code
...
dependencies {
...
compile project(':react-native-dynamic-splash')
}
...
- android/app/src/main/java/com/example/MainApplication.java File add code
... // Import package
iOS
Installing via CocoaPods
- Added in Podfile file
pod 'RNDynamicSplash', :path => '../node_modules/react-native-dynamic-splash'
- Then run pod install
Manual installation
- In XCode, in the project navigator, right click Libraries ➜ Add Files to [your project's name]
- Go to node_modules ➜ react-native-dynamic-splash and add RNDynamicSplash.xcodeproj
- In XCode, in the project navigator, select your targets. Add libRNDynamicSplash.a to your project's Build Phases ➜ Link Binary With Libraries
- To fix 'RNDynamicSplash.h' file not found, you have to select your project/targets → Build Settings → Search Paths → Header Search Paths to add:
- project $(SRCROOT)/../node_modules/react-native-dynamic-splash/ios recursive
- targets $(inherited) recursive
Usage
Android
- MainActivity.java File
...
iOS
- AppDelegate.m File
... ...
Configuration
type | Field | defaultValue | setter | description |
---|---|---|---|---|
String | imageUrl | "" | setImageUrl | Download picture address |
String | splashSavePath | /splash/ | setSplashSavePath | Save image address |
int | themeResId(Android only) | R.style.DynamicSplash_Theme | setThemeResId | Use theme resource id |
int | layoutResId(Android only) | R.layout.splash_dynamic | setLayoutResId | Use layout file resource id |
boolean | autoDownload | true | setAutoDownload | Whether to download automatically |
boolean | dynamicShow | true | setDynamicShow | Whether to display the downloaded picture |
boolean | autoHide | false | setAutoHide | Whether to automatically hide |
long | autoHideTime | 3000 | setAutoHideTime | Automatically hide time |
Other instructions
- The first time to start displaying the default image, the second time to start displaying the downloaded image again
- Android Can use their own written resource files and topics, and the same name as the default configuration, otherwise call the set method to change the configuration, reference package resource file
- Android doesn't set imageUrl to show resource image in layout file
- ios does not set imageUrl to show picture of LaunchImage
Provide get request method
Can call the request to get the address of the picture
// mock json data // { // splashInfo: { // imageUrl: "http://***.png" // } // } ... public static void { HttpUtils.;}...
API
name | type | description | conflict |
---|---|---|---|
hide() | function | Js control hidden splash | autoHide not set true |
downloadSplash() | function | Js control download pictures | autoDownload is set to false |
TODO
- Android version splash
- Ios version splash
- js incoming url as image download link
- Configuration add skip button
- Ios rewrite using swift
Changelog
- 1.0.*
- 1.1.*