- (void)setup3DTouch:(UIApplication *)application {
/*
type 该item 唯一标识符
localizedTitle :标题
localizedSubtitle:副标题
icon:icon图标 可以使用系统类型 也可以使用自定义的图片
userInfo:用户信息字典 自定义参数,完成具体功能需求
*/
UIApplicationShortcutIcon *QRCodeIcon = [UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypeCapturePhoto];
UIApplicationShortcutItem *QRCodeItem = [[UIApplicationShortcutItem alloc]initWithType:@"QRCode" localizedTitle:@"扫码" localizedSubtitle:@"" icon:QRCodeIcon userInfo:nil];
UIApplicationShortcutIcon *recordingIcon = [UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypePlay];
UIApplicationShortcutItem *recordingItem = [[UIApplicationShortcutItem alloc]initWithType:@"Recording" localizedTitle:@"录音" localizedSubtitle:@"" icon:recordingIcon userInfo:nil];
//将items添加到app图标
application.shortcutItems = @[QRCodeItem,recordingItem];
}
//图标3DTouch回调
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler {
UINavigationController *nav = (UINavigationController *)tabBarController.selectedViewController;
if ([shortcutItem.type isEqualToString:@"QRCode"]) {
QRCodeViewController *qrvc = [[QRCodeViewController alloc]init];
qrvc.hidesBottomBarWhenPushed = YES;
[nav pushViewController:qrvc animated:YES];
}else if ([shortcutItem.type isEqualToString:@"Recording"]) {
RecordingViewController *recordvc = [[RecordingViewController alloc]init];
recordvc.hidesBottomBarWhenPushed = YES;
[nav pushViewController:recordvc animated:YES];
}
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
self.window.backgroundColor = [UIColor whiteColor];
tabBarController = [[TabBarController alloc]init];
self.window.rootViewController = tabBarController;
[self.window makeKeyAndVisible];
[self setup3DTouch:application];//3D Touch调用
return YES;
}
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。