UIImage from UIApplicationShortcutIcon
Asked Answered
P

3

8

There are some great "Quick Action Icons" available at https://developer.apple.com/ios/human-interface-guidelines/graphics/system-icons/.

Is it possible to make a UIImage from one of these UIApplicationShortcutIcons to use on, say, a UIButton. For example, the mail icon:

let mailIcon = UIApplicationShortcutIcon(type: .mail)
let mailImage = UIImage( ... )

Any help would be appreciated. Thanks.

Persephone answered 25/3, 2017 at 17:33 Comment(0)
T
6

You cannot use Quick Action Icons as an normal image or cannot set in a button image. These are only for 3D touch shortcuts. When you press on application icon and it display shortcut menu for quick action. You can use these icons here. Even it allows to use our images as an quick action icons.

Also you can refer below URLs as a reference :

  1. How to add custom images as UIApplicationShortcutIcon for UIApplicationShortcutItem?
  2. UIApplicationShortcutItem - Can I use an image downloaded from the web as UIApplicationShortcutIcon?
  3. https://developer.apple.com/reference/uikit/uiapplicationshortcuticon
Trachoma answered 28/3, 2017 at 7:40 Comment(1)
Thanks - is there anyway to access these official icons?Persephone
N
2

These images are not available using normal API, but they are part of the UIKit bundle. You can use a tool, such as iOS-Artwork-Extractor, to extract the 1x, 2x and 3x variants of those images, and then you can add them to your project.

Nabila answered 31/3, 2017 at 18:27 Comment(0)
C
1

you can do something like this now:

<dict>
    <key>UIApplicationShortcutItemIconFile</key>
    <string><your image name from assets catalog></string>
</dict>
Capsaicin answered 14/4, 2021 at 9:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.