Set App Logos, Launch Screens, and Icons in React Native

Set the app's launch screen and icons. Learn what image to put in native and what to bundle with React Native. Set the tab bar icons.

Project Source Code

Get the project source code below, and follow along with the lesson material.

Download Project Source Code

To set up the project on your local machine, please follow the directions provided in the README.md file. If you run into any issues with running the project source code, then feel free to reach out to the author in the course's Discord channel.

This lesson preview is part of the The newline Guide to React Native for JavaScript Developers using TypeScript course and can be unlocked immediately with a \newline Pro subscription or a single-time purchase. Already have access to this course? Log in here.

This video is available to students only
Unlock This Course

Get unlimited access to The newline Guide to React Native for JavaScript Developers using TypeScript, plus 70+ \newline books, guides and courses with the \newline Pro subscription.

Thumbnail for the \newline course The newline Guide to React Native for JavaScript Developers using TypeScript

In this lesson, we'll look at how to set the app icons, the launch screens, how to put images on the native side and then use them in React Native and also how to set the tab by icons. We'll also look at how to use badges. For icons, there is one common practice in React Native. You generally upload three versions of any image and they're called at the rate of 2x, 3x and a simple name. Now these are three different versions like let's say we have a base image that has a resolution of 22 by 20, the 2x will have a resolution of 44 by 40 and 66 by 60. In a lot of cases, just uploading the 3x version works and app is able to render that by scaling down or lower it and devices. Except for tab bar icons in this, we are supposed to be uploading all three versions and there are two parts to it. One is an inactive state and one is an active state. We'll look more into how to set all of these in going forward. So let's get started. To set the iOS icons, we can open the project in Xcode and then go to images.x esets folder and then click the app icon available here. It will show all the icons that we need to upload with the sizes that they need to be. So it's pretty intuitive from that perspective. Alternately, we can paste all the images inside this folder that we can find in the project. If you go to iOS, Friday app and we'll find images.xesets and then app icon, we can put everything inside this and then that will also pick up. So let's try using Xcode. So that's there's the project. Remember to open the workspace file and then if you click on images.xesets, app icons, these are all the icons that we need to upload. Now you can have one large image and you can generate all the different sizes that are required. There are a lot of tools available just search for app icon generator and you 'll find it. And I opened the first one and used this tool to create the icons. So I already have them created. As you see, this is the same folder that we need to upload and these are the different sizes. So let's try uploading them. Now the good thing about this is if you upload a wrong size, let's say that we are supposed to be uploading 60 by 60, but we upload 57, it'll give you a warning that. It should be so that that's good. It's harder to make mistakes that way. So let's just upload these. We need 88 and then 87. And then we just run and build and run the project and the icons should be set. That's quite easy. Now if you go to back to the project, you see all these icons have actually been put into the same folder. We just want difference that earlier this content.json, it did not have the file name. So if you plan to do it manually, just add the file name attribute to it. You can keep any name. It's not necessary to keep it as per resolution. And there we have our app icon. So just one thing to remember, don't keep any transparency in these icons, especially on the edges. If we do that, then while launching the borders, they'll show up in black colors, having a black background and that won't look nice, especially while launching and also while closing an app or setting it to home again. Next let's look at Android. For Android, we have quite similar options. One is using the Android Studio. We can open the Android folder inside the boilerplate code, the root folder, this one in Android Studio and then right click on the res folder that is the resources and then simply select image assets inside new. This will open up a wizard. Right here it will give the option to select one image. It should be at least of the size 512 by 512 and the wizard will automatically create the rest of the icons for the app. Alternately, we can also put all the images, all the different icons inside the res folder. Now here it's a little different than iOS. In Android, we have a map map folders. So it will be map map hyphen mdpi, hdpi, xhdpi depending on device resolutions. So we need to put different size images inside these. So for mdpi, it will be 48 by 48 for hdpi to 72 by 72 and so on. So as we see the options are quite similar to iOS. Let's try doing this using Android Studio. It's a simple way. So we just open the Android folder in Android Studio, right click on res, new and then we select image assets. And then currently showing the default that comes bundled in, we can just change the path of the image. So we'll select a large enough image. So this is 512 by 512, just select it, it will automatically create all the different resolutions required. Again remember, don't put anything transparent unless you absolutely are sure about it. From here we can click next and then just finish. And this will automatically set that image as the apps icon with necessary sizes. Let's try and load that. So after uploading the image and clicking finish, I just build and run the Android project. And let's check the icons and there we have it, right? If we check the Android folder, then we'll find that it has already created those different images for different resolution devices. Let's look at setting the launch screens. Now launch screens are not supported by default. For iOS, they do have a launch screen and it's a text that says powered by React Native. I've changed that in the polypate code to have a single image and simply replacing this image at the same location that XC assets is going to work for iOS. For Android, it doesn't support any launch screen by default. We have to create a new screen and add it to the project. And then on Listing for NVC, please swap the splash screen with the React Native default screen on when the bundle loads. So let's look at setting the launch screen on iOS. We again go to App and then Images to Text YC assets, the launch screen. Now this is a part of the polypate code, remember, and simply replace the launch screen images. So I've already created a new image for iOS and Android. So we'll just put that. So this is the 1X image, the 2X and the 3X image. Now from here, we just do Yarn iOS and we'll have the new launch screen that we just set up. There we have it, the new launch screen. For a better user experience, a good practice is to have some kind of continuity between the app icon and the launch screen. Like, we should not have a blue icon and then a green launch screen. There should be some continuity in color, it just makes for a better user experience. It feels like the app just occupied the whole screen to launch. Now for Android, we'll just put the largest image inside the tribal folder. So ultimately, we could also put all the different resolutions. Like, if you go inside App, SRC main res, there's a tribal folder, you could put a single large image over here or you can have those different sizes that we mentioned earlier. X, X, G, P, and all this. So the tribal hype and X, S, G, P, I, we'll just take the largest image that we have and we'll just replace the existing one with it. So currently it's this one, let's just delete this and we'll name it launch screen the same as before and now we'll simply build and run the Android app. Now remember, whenever you make any change on the native side, on iOS and Android, you have to stop the complete application and start it again, either from terminal or from the studios. Changes in the reactive are reflective, but any change on the native side requires a complete rebuild of the project. So let me just do that and come back with the launch screen on Android. So the emulator has started, let's just launch the app. Change the launch screen and then once the app boots, the launch screen will move to the splash screen. The tab bar icons need to be set on the reactive side. It's along with the reactive navigation. Let's look at that. I have already added a few icons for the different tabs that we have. If you recall, we had the home tab and the card and the search and the profile tab. So there we have different resources. So we have a default image and then a 2x and a 3x similarly for home for profile and for search. If you notice, we have cart and then cart and resource active. So these are basically two images to show that a tab is active. So if you go to our navigator and then we just scroll to the part where we configure this so we can set an icon and we can also set a different icon for to display that the tab is active. You just remember these need to be of same sizes. So if cart source is of 22 by 22, the cart active and all the other images that we're using the tab bar need to be of the same size and the 2x and 3x, they go quite similarly. So if we have a 20 by 20, we need to have a 40 by 40 for 2x and a 66, 60 by 64, 3x. So tab bar requires all three images. So we can't just put a 3x image and and assume it to work. So that's something that required and again, like app icons, we can find a lot of tools online where we can put just one image and it will convert all those different sizes for us. So let's try and set these. So we have our home and then we have cart and then we have profile and we have search. So we have home, we have search, let's just do that. Search, let's also start the app. This needs to be done only once because we're doing it on the reactative side. So doing it for iOS, we'll also make it happen for Android. So this is cart, we'll just do cart and we'll do cart underscore active for search, index underscore active and then we have profile. So profile, profile underscore active. Let's just save that and that should work for home. We only have one image and plan to use a selected icon color for that. So let's just do that. We'll do a typography dot color dot. Let's just do morning for now. Save it and let's check. So we have our home icon, search icon, cart and set exactly. We can also change the color of the text and icons if you want. Like if I use something else over here for selected or for default, it will start showing up that way. Okay. Default is white. Let's not do that. Let's do default selected and yes, even the selected one comes as black. So for search, it has replaced the icon, but I think we also have selected icon color and that is why it's also showing that. So let's just comment that out. We don't want that for all of them. So my bad. So that's nice. As you can see, it supports colored images. We can also do that transition between a black and white image and color image in case we want that. Let's try that. Just save it and if you load automatically, we'll have to comment out this little icon color. So yeah, so in case you need that, that looks pretty neat to write. Now let's say if you want to have only the icons and no text in that case in this text attribute, simply set this as empty and we will have only the icons. So it also supports other attributes like font family, font style, font weight in case we want to play with that. You can also set a different font face that is font family for it. Now, like I said, the changes only need to be done once is we're doing it in React Native so the Android icons have also changed. With that, we have looked at setting the app icon, the launch screen and setting the tab bar that starts giving a shape to the app. There's one more thing here if we want to use some image from the native side. So that process is quite simple. We just upload the image on the native side for iOS. It again goes back to this images dot XDS sets. We just right click here, add a new image, add the three variations or just one . But remember to have the largest one and to refer it, we only call the image name. We don't call the full path, we just call the image name and we'll be able to use that inside the app. Similarly for Android, for Android, we put everything inside the Troyable folder. If you remember from the icons app launch screen part, just put it there. If you want put only the largest one and then we can again refer it simply by name and it will work. Remember, these images are on the native side. So to change these images, we actually need to release a build and this will not work over the air with React Native bundle. So that choice needs to be made if you if the images are changing frequently, then it's better to put it on the React Native side inside the assets folder. And if it's a some kind of a launch image or a marketing image that you think it's not going to change that frequently, put it on the native side. Apart from the launch images and icons, they go in the native. So if you want to change that, we have to do an app. For that the tab bar icons, although can be changed from React Native. So let's just put an image on the native side and use it, which is good to our project folder, XDS sets and here we can right click and create a new image set. So let's call it sample and here we upload the three sizes or just the largest one. I have a sample size here, sample image here. So I just upload it. Now remember, we're calling it sample. So if you want to refer it, we have to refer it by this name. So let's just go to home component and let's use an image. So we just copy this over and we'll say source. So the new RI is sample. Let's start looking at the native. Now remember, this is a native change. So we have to actually build the whole project and run it. Otherwise the React Native app will not be able to find this image. So let's go to the app and okay, we need to put in a size. Otherwise this won't work. For now, we'll reuse that and there we have our image. This from the native. Just remember, while making these changes, it tends to happen that we add the images to one platform and forget it for the other. So just be careful of that because this is this common code base. So now it will also look for the sample image inside the Android app and we need to put that inside the drawables folder for Android. So just put the largest image and that should be good. So last, let's look at the badges. So these are the notification icons that we see. We can put them, we can use them on the navigation bars. Like let's say that we have a pending action on settings. So we can store the particular value that we want inside state or async storage and then we can just populate it for now. Let's just populate it manually. For that, we need to set the badge. It takes a string. So we'll just put one and for badge color, we will do typography dot color dot warning, save it, reloads and we have our badge. It's a string so it can take anything. So it's flexible that way if you want to do it. [BLANK_AUDIO]