Start a Project

How To Change App Icon Runtime in Swift

In this blog we will learn about How To Change App Icon Runtime in Swift.

How To Change App Icon Runtime in Swift

Introduction

In iOS, developers can provide alternate app icons that users can switch between without needing to reinstall the app. iOS 10.3 finally gave developers the ability to change their app’s icon programmatically, although it takes a little work to set up.

Implementation

Follow the steps to change the App Icon.

Step 1:

First of all you need to create a new project where you will implement How To Change App Icon Runtime in Swift.

Step 2:

After that you need to create a UIViewController (ViewController).

A ViewController is a fundamental building block of an app’s user interface. It manages a single screen of content and handles user interactions.

Step 3:

Create @2x & @3x image for App Icon.

 

Step 4:

The actual code to change your app’s icon is trivial, but first, there’s some setup work because you must declare all possible icons in your Info.plist file.

The process behind this is far from optimal, and right now the best thing to do is edit your Info.plist as XML rather than trying to use the built-in property list editor in Xcode.

Step 5:

Add a Method to change the image Icon.

Above mention code is useful to change icon at runtime.

UIApplication.shared.setAlternateIconName(name):

This method in Swift used to change the app’s icon at runtime. 

Step 6:

In this step Now you need to call changeIcon method from any event.

Hope the above blog will help you to change the App icon in runtime in iOS using swift.

Conclusion

In this article we have discussed about How To Change App Icon Runtime in Swift.

I hope this blog is helpful to understand this topic.

You can check here how to set app icon in iOS.
Thanks for reading this blog. You can also check other blogs from here for more knowledge.

Exit mobile version