This article will introduce in detail how the APP sets the name, icon and startup page from the two ends of Android
and respectively.IOS
First, we go to the icon factory to upload an 1024x1024
icon, and then generate icons of all sizes with one click, and download them for use at both ends.
IOS side
setting name
In Xcode, click on your project to modify Display Name
the name of the APP on the right side
settings icon
Open the icon group folder downloaded above, and drag the entire directory into the directory of the project ios
to replace the original file.AppIcon.appiconset
ios/rn(工程名)/Images.xcassets
Go back to Xcode and you can see that icons of all sizes have been set successfully
Re-run the project to see the icon.
If re-running the project icon still does not take effect, please confirm Copy Bundle Resources
whether there isImages.xcassets
Set startup page
First install react-native-splash-screen
yarn add react-native-splash-screen
Then enter ios
the directory and executepod install
Open the project with Xcode, AppDelegate.m
import RNSplashScreen.h
the file in the file, and add the display code.
#import "RNSplashScreen.h" // 导入
[RNSplashScreen show]; // 显示启动屏
Then create a startup map container
image.png
The same is still going to the icon factory to make a startup image
image.png
ios
Drag the under directory in the downloaded startup image folder LaunchImage.launchimage
into ios/rn(工程名)/Images.xcassets
to replace the original file.
image.png
then view App Icons and Launch Images
items
image.png
We need to Launch Screen File
leave empty, so that the default will not be LaunchScreen.storyboard
used
So we need to Build Settings
search in Asset Catalog Launch Image Set Name
and then create the startup page name
image.png
Then modify info
it inLaunch screen interface file base name
LaunchImage
image.png
The latter Value
is changed toLaunchImage
image.png
Finally, set how long to close the startup map in the home page in RN
import React from 'react';
import {Text, StyleSheet, View, Dimensions} from 'react-native';
import SplashScreen from 'react-native-splash-screen';
export default class Home extends React.Component {
componentDidMount() {
setTimeout(() => {
SplashScreen.hide();
}, 3000);
}
render() {
return (
<View style={styles.content}>
<Text style={
{fontFamily: 'FZSJ-LIANGWZDQS'}}>
智者一切求自己,愚者一切求他人。
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
content: {
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
width: Dimensions.get('window').width,
height: Dimensions.get('window').height,
},
});
Restart to see the effect
LaunchImage.png
Android side
setting name
modify android/app/src/main/res/values/strings.xml
file
<resources>
<string name="app_name">自动驾驶</string>
</resources>
settings icon
Open the icon group folder downloaded above, and drag android
the 6 folders under the directory into android/app/src/main/res
the directory to replace them. and change both the and android/app/src/main/AndroidManifest.xml
of the file to the name of the iconicon
roundIcon
image.png
image.png
Recompile and run to see the effect
Set startup page
android
Drag the 6 folders under the directory in the downloaded startup image folder into android/app/src/main/res
the directory.
image.png
android/settings.gradle
Add these two lines of code to the file
include ':react-native-splash-screen'
project(':react-native-splash-screen').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-splash-screen/android')
image.png
Then android/app/build.gradle
import in the filereact-native-splash-screen
implementation project(':react-native-splash-screen')
image.png
Then android/app/src/main/java/com.rn(项目名)/MainActivity.java
import the Android package in the file
import android.os.Bundle;
import org.devio.rn.splashscreen.SplashScreen;
@Override
protected void onCreate(Bundle savedInstanceState) {
SplashScreen.show(this); // 显示
super.onCreate(savedInstanceState);
}
image.png
android/app/src/main/java/com.rn(项目名)/MainApplication.java
Introduce in the file
import org.devio.rn.splashscreen.SplashScreenReactPackage;
image.png
android/app/src/main/res
Create a folder under and create a file layout
under that folderlaunch_screen.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/screen">
</LinearLayout>
Create a file under android/app/src/main/res/values
the foldercolor.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="primary_dark">#000000</color>
</resources>
In android/app/src/main/res/values/styles.xml
the file add
<!--设置透明背景-->
<item name="android:windowIsTranslucent">true</item>
image.png
Recompile to see the effect
Author: Infinity 369
Link: https://www.jianshu.com/p/ce7ee8efd42c