iOS

iOS 3D toouch功能

2017-02-23  本文已影响8人  迎风起飞的猪


- (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(@"收藏");

}

}

上一篇下一篇

猜你喜欢

热点阅读