Skip to content

Instantly share code, notes, and snippets.

@alana-mullen
Last active April 12, 2017 23:52
Show Gist options
  • Save alana-mullen/684601e86f2d8c283c65 to your computer and use it in GitHub Desktop.
Save alana-mullen/684601e86f2d8c283c65 to your computer and use it in GitHub Desktop.
Use current iOS app icon with UIImageView in Swift 2 (Swift 3 example: https://gist.github.com/thewirelessguy/b0eba855c0307b47168be85291788746)
let primaryIconsDictionary = NSBundle.mainBundle().infoDictionary?["CFBundleIcons"]?["CFBundlePrimaryIcon"] as? NSDictionary
let iconFiles = primaryIconsDictionary!["CFBundleIconFiles"] as! NSArray
let lastIcon = iconFiles.lastObject as! NSString //last seems to be largest, use first for smallest
let theIcon = UIImage(named: lastIcon as String)
let iconImageView = UIImageView(image: theIcon)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment