UIImage from UIApplicationShortcutIcon

笑着哭i 提交于 2019-12-22 04:54:08

问题


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.


回答1:


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



回答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.



来源:https://stackoverflow.com/questions/43019653/uiimage-from-uiapplicationshortcuticon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!