- (void)createDynamicShortcutItems { // create several (dynamic) shortcut items UIApplicationShortcutItem *item1 = [[UIApplicationShortcutItem alloc]initWithType:@"Item 1" localizedTitle:@"Item 1"]; UIApplicationShortcutItem *item2 = [[UIApplicationShortcutItem alloc]initWithType:@"Item 2" localizedTitle:@"Item 2"]; UIApplicationShortcutItem *item3 = [[UIApplicationShortcutItem alloc]initWithType:@"Item 3" localizedTitle:@"Item 3"]; // add all items to an array NSArray *items = @[item1, item2, item3]; // add the array to our app [UIApplication sharedApplication].shortcutItems = items;}
修改
- (void)modDynamicShortcutItems{ NSArray*existingShortcutItems = [[UIApplication sharedApplication] shortcutItems]; NSInteger anIndex = 1; UIApplicationShortcutItem *anExistingShortcutItem = [existingShortcutItems objectAtIndex: anIndex]; NSMutableArray *updatedShortcutItems = [existingShortcutItems mutableCopy]; UIMutableApplicationShortcutItem *aMutableShortcutItem = [anExistingShortcutItem mutableCopy]; [aMutableShortcutItem setLocalizedTitle: @"New Title"]; [updatedShortcutItems replaceObjectAtIndex: anIndex withObject: aMutableShortcutItem]; [[UIApplication sharedApplication] setShortcutItems: updatedShortcutItems];}
静态info.plist
UIApplicationShortcutItemIconType UIApplicationShortcutIconTypeSearch UIApplicationShortcutItemSubtitle shortcutSubtitle1 UIApplicationShortcutItemTitle shortcutTitle1 UIApplicationShortcutItemType $(PRODUCT_BUNDLE_IDENTIFIER).First UIApplicationShortcutItemUserInfo firstShorcutKey1 firstShortcutKeyValue1 UIApplicationShortcutItemIconType UIApplicationShortcutIconTypeShare UIApplicationShortcutItemSubtitle shortcutSubtitle2 UIApplicationShortcutItemTitle shortcutTitle2 UIApplicationShortcutItemType $(PRODUCT_BUNDLE_IDENTIFIER).Second UIApplicationShortcutItemUserInfo secondShortcutKey1 secondShortcutValue1
swift
官方参考 :
文档 概述
UITouch对象中的压力属性
在iOS 9中,UITouch类获得了两个全新的属性帮助你在应用中自定义3D Touch: 和。
这些属性可以让你侦测并响应APP接收的对象中的触摸压力。在iPhone上,触控压力感应有很大的动态范围,对于你的应用来说它是个浮点值。有关更多自定义使用压力值对3D Touch的实现,请阅读以下资料:
在 中对 和 属性的描述.
(示例代码)