iOS 3D toouch功能
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
UIApplicationShortcutIcon *shortIcon1 = [UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypeAdd];
UIApplicationShortcutItem *item1 = [[UIApplicationShortcutItem alloc] initWithType:@"add" localizedTitle:@"添加" localizedSubtitle:@"添加一个好友" icon:shortIcon1 userInfo:nil];
UIApplicationShortcutIcon *shortIcon2 = [UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypeFavorite];
UIApplicationShortcutItem *item2 = [[UIApplicationShortcutItem alloc] initWithType:@"collection" localizedTitle:@"收藏" localizedSubtitle:@"收藏一个故事" icon:shortIcon2 userInfo:nil];
application.shortcutItems = @[item1,item2];
return YES;
}
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler{
if ([shortcutItem.type isEqualToString:@"add"]) {
NSLog(@"添加");
}
if ([shortcutItem.type isEqualToString:@"collection"]) {
NSLog(@"收藏");
}
}
上一篇下一篇