3D Touch初探

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.

https://developer.apple.com/ios/3d-touch/




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;

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.
 */
- (instancetype)initWithType:(NSString*)type localizedTitle:(NSString*)localizedTitle localizedSubtitle:(nullableNSString *)localizedSubtitle icon:(nullableUIApplicationShortcutIcon *)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 );
}


6)UIApplicationShortcutItem的名字本地化

在UIApplicationShortcutItemTitle 键值写下相应的字符,然后在InfoPlist.strings中添加本地化字符即可


例如:

"ShortcutTitleHidePhoto" = "Hide Photo";
"ShortcutTitlePrivateCamera" = "Private Camera";
"ShortcutTitleFastScanCode" = "Fast Scan Code";












  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值