#if USE_UIKIT_PUBLIC_HEADERS || !__has_include(<UIKitCore/UIApplicationShortcutItem.h>)
//
// UIApplicationShortcutItem.h
// UIKit
//
// Copyright © 2015-2018 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKitDefines.h>
NS_ASSUME_NONNULL_BEGIN
@class UIImage;
/* App快捷方式系统图标 <枚举> */
typedef NS_ENUM(NSInteger, UIApplicationShortcutIconType) {
UIApplicationShortcutIconTypeCompose,
UIApplicationShortcutIconTypePlay, // 播放箭头
UIApplicationShortcutIconTypePause,
UIApplicationShortcutIconTypeAdd, // 加号
UIApplicationShortcutIconTypeLocation,
UIApplicationShortcutIconTypeSearch,
UIApplicationShortcutIconTypeShare,
UIApplicationShortcutIconTypeProhibit NS_ENUM_AVAILABLE_IOS(9_1),
UIApplicationShortcutIconTypeContact NS_ENUM_AVAILABLE_IOS(9_1),
UIApplicationShortcutIconTypeHome NS_ENUM_AVAILABLE_IOS(9_1), // 小房子
UIApplicationShortcutIconTypeMarkLocation NS_ENUM_AVAILABLE_IOS(9_1),
UIApplicationShortcutIconTypeFavorite NS_ENUM_AVAILABLE_IOS(9_1),
UIApplicationShortcutIconTypeLove NS_ENUM_AVAILABLE_IOS(9_1), // 心形
UIApplicationShortcutIconTypeCloud NS_ENUM_AVAILABLE_IOS(9_1),
UIApplicationShortcutIconTypeInvitation NS_ENUM_AVAILABLE_IOS(9_1),
UIApplicationShortcutIconTypeConfirmation NS_ENUM_AVAILABLE_IOS(9_1),
UIApplicationShortcutIconTypeMail NS_ENUM_AVAILABLE_IOS(9_1), // 邮件
UIApplicationShortcutIconTypeMessage NS_ENUM_AVAILABLE_IOS(9_1), // 信息
UIApplicationShortcutIconTypeDate NS_ENUM_AVAILABLE_IOS(9_1),
UIApplicationShortcutIconTypeTime NS_ENUM_AVAILABLE_IOS(9_1), // 表
UIApplicationShortcutIconTypeCapturePhoto NS_ENUM_AVAILABLE_IOS(9_1),
UIApplicationShortcutIconTypeCaptureVideo NS_ENUM_AVAILABLE_IOS(9_1),
UIApplicationShortcutIconTypeTask NS_ENUM_AVAILABLE_IOS(9_1),
UIApplicationShortcutIconTypeTaskCompleted NS_ENUM_AVAILABLE_IOS(9_1),
UIApplicationShortcutIconTypeAlarm NS_ENUM_AVAILABLE_IOS(9_1),
UIApplicationShortcutIconTypeBookmark NS_ENUM_AVAILABLE_IOS(9_1),
UIApplicationShortcutIconTypeShuffle NS_ENUM_AVAILABLE_IOS(9_1),
UIApplicationShortcutIconTypeAudio NS_ENUM_AVAILABLE_IOS(9_1), // 音乐
UIApplicationShortcutIconTypeUpdate NS_ENUM_AVAILABLE_IOS(9_1)
} API_AVAILABLE(ios(9.0)) API_UNAVAILABLE(tvos) API_UNAVAILABLE(macos);
#pragma mark - App快捷方式系统配图类
#pragma mark -
UIKIT_EXTERN API_AVAILABLE(ios(9.0)) API_UNAVAILABLE(tvos) API_UNAVAILABLE(macos)
@interface UIApplicationShortcutIcon : NSObject <NSCopying>
// 使用系统定义的图像设置图标
+ (instancetype)iconWithType:(UIApplicationShortcutIconType)type;
// 从自定义图像创建图标
+ (instancetype)iconWithTemplateImageName:(NSString *)templateImageName;
@end
#pragma mark - App快捷方式类
#pragma mark -
/*
- UIApplicationShortcutItem
应用程序快捷方式项,也称为主屏幕动态快速操作,即主屏幕利用3D Touch点击App弹出的快捷方式
- 概述
在支持3D Touch的设备上,用户通过按主屏幕上的应用程序图标然后选择快速操作的标题来调用快速操作.您的App delegate接收并处理快速操作。
在向应用程序对象注册之前,必须在初始化期间指定UIApplicationShortcutItem实例的特征.您在app对象中注册的快速操作是不可变的。
可用代码方式添加到Applicatio里,也可以静态添加到info.plist里
*/
UIKIT_EXTERN API_AVAILABLE(ios(9.0)) API_UNAVAILABLE(tvos) API_UNAVAILABLE(macos)
@interface UIApplicationShortcutItem : NSObject <NSCopying, NSMutableCopying>
/* 实例化 */
- (instancetype)init NS_UNAVAILABLE;
/**
实例化(带图标和其他配置的快捷方式)
@param type 系统类型
@param localizedTitle 标题文字
@param localizedSubtitle 子标题文字
@param icon 系统图标
@param userInfo 用户自定义信息
@return UIApplicationShortcutItem
*/
- (instancetype)initWithType:(NSString *)type localizedTitle:(NSString *)localizedTitle localizedSubtitle:(nullable NSString *)localizedSubtitle icon:(nullable UIApplicationShortcutIcon *)icon userInfo:(nullable NSDictionary<NSString *, id <NSSecureCoding>> *)userInfo NS_DESIGNATED_INITIALIZER;
/**
实例化(不带图标的快捷方式)
@param type 系统类型
@param localizedTitle 标题文字
@return UIApplicationShortcutItem
*/
- (instancetype)initWithType:(NSString *)type localizedTitle:(NSString *)localizedTitle;
// 获取 快捷方式类型(特定的字符串)
@property (nonatomic, copy, readonly) NSString *type;
// 获取 标题文字
@property (nonatomic, copy, readonly) NSString *localizedTitle;
// 获取 子标题文字
@property (nullable, nonatomic, copy, readonly) NSString *localizedSubtitle;
// 获取 App快捷方式系统配图
@property (nullable, nonatomic, copy, readonly) UIApplicationShortcutIcon *icon;
// 获取 用户自定义信息(如果NSDictionary不是可编码的,则会抛出异常)
@property (nullable, nonatomic, copy, readonly) NSDictionary<NSString *, id <NSSecureCoding>> *userInfo;
@end
#pragma mark - App快捷方式类(可修改的)
#pragma mark -
UIKIT_EXTERN API_AVAILABLE(ios(9.0)) API_UNAVAILABLE(tvos) API_UNAVAILABLE(macos)
@interface UIMutableApplicationShortcutItem : UIApplicationShortcutItem
// 设置 快捷方式类型(特定的字符串)
@property (nonatomic, copy) NSString *type;
// 设置 标题文字
@property (nonatomic, copy) NSString *localizedTitle;
// 设置 子标题文字
@property (nullable, nonatomic, copy) NSString *localizedSubtitle;
// 设置 App快捷方式系统配图
@property (nullable, nonatomic, copy) UIApplicationShortcutIcon *icon;
// 设置 用户自定义信息(如果NSDictionary不是可编码的,则会抛出异常)
@property (nullable, nonatomic, copy) NSDictionary<NSString *, id <NSSecureCoding>> *userInfo;
@end
NS_ASSUME_NONNULL_END
#else
#import <UIKitCore/UIApplicationShortcutItem.h>
#endif
网友评论