Created
March 14, 2017 03:07
-
-
Save alana-mullen/b0eba855c0307b47168be85291788746 to your computer and use it in GitHub Desktop.
Use current iOS app icon with UIImageView in Swift 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// GetAppIcon.swift | |
// | |
// Get the AppIcon from Assets and return it as a UIImage | |
// Created by Stephen Mullen | |
// | |
import UIKit | |
func getAppIcon() -> UIImage { | |
let iconsDictionary = Bundle.main.infoDictionary?["CFBundleIcons"] as? NSDictionary | |
let primaryIconsDictionary = iconsDictionary?["CFBundlePrimaryIcon"] as? NSDictionary | |
let iconFiles = primaryIconsDictionary!["CFBundleIconFiles"] as! NSArray | |
// First will be smallest for the device class, last will be the largest for device class | |
let lastIcon = iconFiles.lastObject as! NSString | |
let icon = UIImage(named: lastIcon as String) | |
return icon! | |
} |
ftp27
commented
Sep 5, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment