设为首页 加入收藏

TOP

你想知道的3D Touch开发全在这里了(四)
2019-08-26 06:59:36 】 浏览:96
Tags:知道 Touch 开发 全在 这里
PI_UNAVAILABLE(tvos) API_UNAVAILABLE(macos) @interface UIApplicationShortcutItem : NSObject <NSCopying, NSMutableCopying> - (instancetype)init NS_UNAVAILABLE; - (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; - (instancetype)initWithType:(NSString *)type localizedTitle:(NSString *)localizedTitle; // An application-specific string that identifies the type of action to perform. @property (nonatomic, copy, readonly) NSString *type; // Properties controlling how the item should be displayed on the home screen. @property (nonatomic, copy, readonly) NSString *localizedTitle; @property (nullable, nonatomic, copy, readonly) NSString *localizedSubtitle; @property (nullable, nonatomic, copy, readonly) UIApplicationShortcutIcon *icon; // Application-specific information needed to perform the action. // Will throw an exception if the NSDictionary is not plist-encodable. @property (nullable, nonatomic, copy, readonly) NSDictionary<NSString *, id <NSSecureCoding>> *userInfo; @end UIKIT_EXTERN API_AVAILABLE(ios(9.0)) API_UNAVAILABLE(tvos) API_UNAVAILABLE(macos) @interface UIMutableApplicationShortcutItem : UIApplicationShortcutItem // An application-specific string that identifies the type of action to perform. @property (nonatomic, copy) NSString *type; // Properties controlling how the item should be displayed on the home screen. @property (nonatomic, copy) NSString *localizedTitle; @property (nullable, nonatomic, copy) NSString *localizedSubtitle; @property (nullable, nonatomic, copy) UIApplicationShortcutIcon *icon; // Application-specific information needed to perform the action. // Will throw an exception if the NSDictionary is not plist-encodable. @property (nullable, nonatomic, copy) NSDictionary<NSString *, id <NSSecureCoding>> *userInfo; @end NS_ASSUME_NONNULL_END #else #import <UIKitCore/UIApplicationShortcutItem.h> #endif

常用方法:
创建一个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;
 
- (instancetype)initWithType:(NSString *)type localizedTitle:(NSString *)localizedTitle;

其中:

  • type代表:必传,app定义的主屏幕快速操作类型,可以用于确定某元素点击
  • localizedTitle:展示的title
  • localizedSubtitle:sub title
  • icon:该item左侧或者右侧的icon,类型为UIApplicationShortcutIcon
  • userInfo:用户自定义的一些信息
1.3.2.UIApplicationShortcutIcon

icon有两种获取方式:一种是使用系统自带的类型,一种是用户自定义(根据图片名)。

1.3.2.1 系统自带类型
// Create an icon using a system-defined image.
+ (instancetype)iconWithType:(UIApplicationShortcutIconType)type;

系统自带类型包括以下几种:

系统自带icon类型

1.3.2.1 用户自定义
// Create an icon from a custom image.
// The provided image named will be loaded from the app's bundle
// and will be masked to conform to the system-defined icon style.
+ (instancetype)iconWithTemplateImageName:(NSString *)templateImageName;

首页 上一页 1 2 3 4 5 6 下一页 尾页 4/6/6
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇iOS/OSX漏洞分析和再现:CVE-2019.. 下一篇mac上cocoapods安装与卸载

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目