两种方式
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
网友评论