1

I need to change the color of Application Icon programmatically in iOS.

I’m working on theme based application, where I need to apply theme colors on visual contents of the application, that user selects from a list of colors. The complete app is working fine (able to change colors of all components according to the theme selected by the user) except application Icon.

Is there any way to change/reset application icon/image programmatically. Or I can change app icon/Image tint color?

Here is the same question with both positive & negative answers and both are upvoted. (Can I change app icon programmatically). It creates confusion, whether it is possible or not. And if yes, then how can I do that?

Note: I have requirement different than other questions/answers, I have a list of colors (around 25) in-app and I need to change icon color, according to user's selection of color, from the app. Can anyone guide a proper way to utilize/use a single set of app icons and apply different colors on it?

Jonathan Willcock
  • 5,012
  • 3
  • 20
  • 31
Krunal
  • 77,632
  • 48
  • 245
  • 261

1 Answers1

4

It is possible to change appIcon from iOS 10.3. For this you need to set supportsAlternateIcon to Yes in info.plist. Both primary and secondary icons should be added in CFBundleIcons key of your app's Info.plist file.

To change App Icon following UIApplication method is to be called:

func setAlternateIconName(_ alternateIconName: String?,  completionHandler: ((Error?) -> Void)? = nil)

Reference

Priyal
  • 879
  • 1
  • 9
  • 30
  • Trying this answer but Looking for more efficient answer, as I've list of colors (around 25) and I need to change icon color, that user selects from app. Will it be possible with your answer? – Krunal May 01 '17 at 10:48
  • You would need to add 25 different icons to your bundle; all icons need to be included in the bundle when you create it. You can only select one of the included icons; you cannot create a new one at runtime – Paulw11 May 01 '17 at 12:22
  • @Paulw11 can you guide a proper way to utilize/use single set of icons and apply different colors on it. – Krunal May 01 '17 at 13:36
  • You just need to create your different icons and add them to your app bundle. You can then select the required one by name using the function that Priyal has in this answer. Not much else to show. – Paulw11 May 01 '17 at 21:22