Instance Method

setAlternateIconName(_:completionHandler:)

Changes the app's icon.

Declaration

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

Parameters

alternateIconName

The name of the alternate icon, as declared in the CFBundleAlternateIcons key of your app's Info.plist file. Specify nil if you want to display the app's primary icon, which you declare using the CFBundlePrimaryIcon key. Both keys are subentries of the CFBundleIcons key in your app's Info.plist file.

completionHandler

A handler to be executed with the results. After attempting to change your app's icon, the system reports the results by calling your handler. (The handler is executed on a UIKit-provided queue, and not necessarily on your app's main queue.) The handler has no return value and takes the following parameter:

error

On success, the value of this parameter is nil. If an error occurred, this parameter contains the error object indicating what happened and the value of the alternateIconName property remains unchanged.

Discussion

Use this method to change your app's icon to its primary icon or to one of its alternate icons. You can change the icon only if the value of the supportsAlternateIcons property is true.

You must declare your app's primary and alternate icons using the CFBundleIcons key of your app's Info.plist file. For information about how to configure alternate icons for your app, see the description of the CFBundleIcons key in Information Property List Key Reference.

See Also

Managing the App's Icon

var applicationIconBadgeNumber: Int

The number currently set as the badge of the app icon in Springboard.

var supportsAlternateIcons: Bool

A Boolean value indicating whether the app is allowed to change its icon.

var alternateIconName: String?

The name of the icon being displayed for the app.