3D Touch 主要应用:
(1)Quick Actions
Quick Actions let users do the things they do most often, faster and in fewer steps. Many of these actions can even be done with a single press, right from the Home screen.
(2)Peek and Pop
Let your users preview all kinds of content and even act on it — without having to actually open it. Users can then press a little deeper to Pop into content.
(3)Pressure Sensitivity
Drawing and other creative apps can take advantage of the pressure-sensing capabilities of the iPhone 6s and
iPhone 6s Plus
display, for example to make lines thicker or give a brush a changing style.
Quick Actions 的应用:通过3D Touch 手势从主屏幕应用Icon进入,通过弹出来的菜单进入相应地应用模块。类似Push,TodayWidget和桌面快捷方式。
1)UIApplicationShortcutIcon:可以使用自定义图标和系统图标
+ (
instancetype
)iconWithType:(
UIApplicationShortcutIconType
)type;
// 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;
// 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;
2)UIApplicationShortcutIconType:系统图标样式,9.1新加22种,一般使用自定义图标。
3)
UIApplicationShortcutItem 和
UIMutableApplicationShortcutItem (
动态标签
)
UIApplicationShortcutItem
/**
* @param type The required, app-defined type of the Home screen quick action.
* @param localizedTitle The required, user-visible title of the Home screen quick action.
* @param localizedSubtitle The optional, user-visible subtitle of the Home screen quick action.
* @param icon The optional icon for the Home screen quick action.
* @param userInfo App-defined information about the Home screen quick action, to be used by your app to implemebnt the action.
This method throws an exception if the value of this parameter is not property-list-encodable. For more information, see Serializing Property Lists in Archives and Serializations Programming Guide and NSPropertyListSerialization Class Reference.
* @param type The required, app-defined type of the Home screen quick action.
* @param localizedTitle The required, user-visible title of the Home screen quick action.
* @param localizedSubtitle The optional, user-visible subtitle of the Home screen quick action.
* @param icon The optional icon for the Home screen quick action.
* @param userInfo App-defined information about the Home screen quick action, to be used by your app to implemebnt the action.
This method throws an exception if the value of this parameter is not property-list-encodable. For more information, see Serializing Property Lists in Archives and Serializations Programming Guide and NSPropertyListSerialization Class Reference.
*/
- (instancetype)initWithType:(NSString *)type localizedTitle:(NSString *)localizedTitle localizedSubtitle:(nullable NSString *)localizedSubtitle icon:(nullable UIApplicationShortcutIcon *)icon userInfo:(nullable NSDictionary *)userInfo
type 和
localizedTitle是必填项,type可以用来区分点击的是哪个图标进入应用。
localizedTitle是一级标题,
localizedSubtitle是二级标题,
userInfo用来进行点击后传递数据
UIMutableApplicationShortcutItem (
UIApplicationShortcutItem的子类,
可用于动态的改变)
4)
静态标签
除了用代码创建,静态标签也可以用在plist中配置,这样用户安装后就可以通过弹出菜单进入应用模块。
静态标签和动态标签最多可以添加四个
5)点击后的响应
和推送一样,也是在AppDelegate中的代理回调方法中进行
//Called when the user selects a Home screen quick action for your app, except when you’ve intercepted the interaction in a launch method.
- (
void
)application:(
UIApplication
*)application performActionForShortcutItem:(
UIApplicationShortcutItem
*)shortcutItem completionHandler:(
void
(^)(
BOOL
))completionHandler
{
NSLog ( @"shortcutItem%@" ,shortcutItem);
completionHandler( YES );
{
NSLog ( @"shortcutItem%@" ,shortcutItem);
completionHandler( YES );
}
6)UIApplicationShortcutItem的名字本地化
在UIApplicationShortcutItemTitle 键值写下相应的字符,然后在InfoPlist.strings中添加本地化字符即可