美文网首页
添加3DTouch

添加3DTouch

作者: 叫我小黑 | 来源:发表于2018-10-23 21:24 被阅读0次

    两种方式

    1、纯代码添加

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        // Override point for customization after application launch.
        
        self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[ViewController new]];
        
        UIApplicationShortcutIcon * icon1 = [UIApplicationShortcutIcon iconWithTemplateImageName:@"photo_rocket"];
        /**
         type 该item唯一表示符
         localizedTitle 标题
         localizedSubTitle 副标题
         icon 图标,可以用系统类型,也可以自定义使用图片
         userInfo:用户信息字典,自定义参数,完成具体功能需求
         */
        UIApplicationShortcutItem * item1 = [[UIApplicationShortcutItem alloc] initWithType:@"com.3DTouchDemo.item1" localizedTitle:@"windowPhone" localizedSubtitle:@"weiruan" icon:icon1 userInfo:nil];
        UIApplicationShortcutIcon * icon2 = [UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypeBookmark];
        UIApplicationShortcutItem * item2 = [[UIApplicationShortcutItem alloc] initWithType:@"com.3DTouchDemo.Item2" localizedTitle:@"iOS" localizedSubtitle:@"Apple" icon:icon2 userInfo:nil];
        UIApplicationShortcutIcon * icon3 = [UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypeMessage];
        UIApplicationShortcutItem * item3 = [[UIApplicationShortcutItem alloc] initWithType:@"com.3DTouchDemo.Item3" localizedTitle:@"android" localizedSubtitle:@"google" icon:icon3 userInfo:nil];
        
        //将Items添加到app图标
        application.shortcutItems = @[item2,item3,item1];
        
        return YES;
    }
    
    #pragma mark - 3D touch 代理方法
    -(void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler
    {
        if ([shortcutItem.type isEqualToString:@"com.3DTouchDemo.Item2"])
        {
            
        }
    }
    
    

    2、在info.plist上面添加

    1738688-6100eac5309647ff.png

    相关文章

      网友评论

          本文标题:添加3DTouch

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