iOS_3DTouch使用

  • 只支持iOS9.0以后的系统
  • 使用方法如下
	// 创建item
    UIApplicationShortcutItem *item = [[UIApplicationShortcutItem alloc] initWithType:@"type1" localizedTitle:@"标题1" localizedSubtitle:@"副标题1" icon:[UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypeCompose] userInfo:nil];
    UIApplicationShortcutItem *itemTwo = [[UIApplicationShortcutItem alloc] initWithType:@"type2" localizedTitle:@"标题2" localizedSubtitle:@"副标题2" icon:[UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypePlay] userInfo:nil];
    UIApplicationShortcutItem *itemThird = [[UIApplicationShortcutItem alloc] initWithType:@"type3" localizedTitle:@"标题3" localizedSubtitle:@"副标题2" icon:[UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypeLocation] userInfo:nil];
    // 将item加入配置
    [UIApplication sharedApplication].shortcutItems = @[item, itemTwo, itemThird];
// 点击item回调
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler{
    NSLog(@"localizedTitle=%@",shortcutItem.localizedTitle);
    NSLog(@"localizedSubtitle=%@",shortcutItem.localizedSubtitle);
    NSLog(@"type=%@",shortcutItem.type);

}

你可能感兴趣的:(Objective-C)