Skip to content

Instantly share code, notes, and snippets.

@bmontag
Last active May 2, 2020 20:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmontag/b57f6d456b4aeb4483a0678453652089 to your computer and use it in GitHub Desktop.
Save bmontag/b57f6d456b4aeb4483a0678453652089 to your computer and use it in GitHub Desktop.
Change Programmatically your App Icon
var current: BMAppIcon {
return BMAppIcon.allCases.first(where: {
$0.name == UIApplication.shared.alternateIconName
}) ?? .classic
}
func setIcon(_ appIcon: BMAppIcon, completion: ((Bool) -> Void)? = nil) {
guard current != appIcon,
UIApplication.shared.supportsAlternateIcons
else { return }
UIApplication.shared.setAlternateIconName(appIcon.name) { error in
if let error = error {
print("Error setting alternate icon \(appIcon.name ?? ""): \(error.localizedDescription)")
}
completion?(error != nil)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment