Giter VIP home page Giter VIP logo

alternateappicon's Introduction

Configuring Your App to Use Alternate App Icons

Add alternate app icons to your app, and let people choose which icon to display.

Overview

The sample code project demonstrates how to configure your app so that people can change the icon that appears on the Home screen, in Spotlight, and elsewhere in the system.

People select an alternate icon in the app interface from a collection that you provide.

Add Icon Assets for the Alternate Icons

For each alternate app icon, the project requires multiple image files that vary in size. The project organizes these files through icon assets under the asset catalog.

The system picks the correct icon image for the current context and target device from the set of options under each icon asset. This ensures that the appearance of the alternate icon remains consistent.

For information on configuring app icons in the asset catalog, see Configuring Your App Icon.

For design guidance, see Human Interface Guidelines > App Icon.

Configure the Asset Catalog Compiler

The system gathers information about the app's icons from the app's information property list file under the top-level key CFBundleIcons. Xcode adds entries to this file for the icons the project specifies through build settings under Asset Catalog Compiler - Options.

For each icon asset that the project specifies by name in the build setting Alternate App Icon Sets, Xcode adds an entry under the key CFBundleAlternateIcons.

Xcode enters the name of the primary app icon asset specified in the build setting Primary App Icon Set Name under the key CFBundlePrimaryIcon. This setting is also available through the App Icons and Launch Images section of the General pane.

For more information on build settings, see Build Settings Reference.

Change the App's Icon

When people select an alternate icon in the app interface, the app calls setAlternateIconName(_:completionHandler:) with the name of the new icon. This tells the system to display the new icon for this app. The system automatically displays an alert notifying people of the change. Passing nil displays the app's primary icon.

UIApplication.shared.setAlternateIconName(iconName) { (error) in
    if let error = error {
        print("Failed request to update the app’s icon: \(error)")
    }
}

View in Source

The current icon's name is available through the property alternateIconName.

alternateappicon's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.