美文网首页
3DTouch简单使用

3DTouch简单使用

作者: 月咏蝴蝶 | 来源:发表于2016-01-04 13:27 被阅读142次

    最近看到有朋友试了一下3DTouch的功能,于是仿照他的代码也试着写了一下。原文链接:kaishener的博客

    先上效果图

    BB0256CFE39E8CA694C71EA5AEF8AE92.png
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
        // Try 3DTouch Function
        UIApplicationShortcutIcon *icon1 = [UIApplicationShortcutIcon iconWithTemplateImageName:@"login_account_icon"];
        UIApplicationShortcutIcon *icon2 = [UIApplicationShortcutIcon iconWithTemplateImageName:@"login_pwd_icon"];
        UIApplicationShortcutIcon *icon3 = [UIApplicationShortcutIcon iconWithTemplateImageName:@"login_check_icon"];
        UIApplicationShortcutItem *item1 = [[UIApplicationShortcutItem alloc] initWithType:@"item1" localizedTitle:@"账号" localizedSubtitle:@"点击账号" icon:icon1 userInfo:nil];
        UIApplicationShortcutItem *item2 = [[UIApplicationShortcutItem alloc] initWithType:@"item2" localizedTitle:@"密码" localizedSubtitle:@"点击密码" icon:icon2 userInfo:nil];
        UIApplicationShortcutItem *item3 = [[UIApplicationShortcutItem alloc] initWithType:@"item3" localizedTitle:@"验证码" localizedSubtitle:@"点击验证码" icon:icon3 userInfo:nil];
        application.shortcutItems = @[item1,item2,item3];
    }
    
    // 3DTouch Function Call Back
    - (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler{
        if ([shortcutItem.type isEqualToString:@"item1"]) {
            NSLog(@"点击账号");
        }
        else if ([shortcutItem.type isEqualToString:@"item2"]){
            NSLog(@"点击密码");
        }
        else{
            NSLog(@"点击验证码");
        }
    }
    

    相关文章

      网友评论

          本文标题:3DTouch简单使用

          本文链接:https://www.haomeiwen.com/subject/cnqahttx.html