美文网首页
App图标上的3D_Touch

App图标上的3D_Touch

作者: 碧海云天V | 来源:发表于2018-02-06 10:51 被阅读22次
切记,3D_Touch是在iOS 9以后才推出来的,要用这个功能时,一定要进行版本判定,不然在低系统版本上就会造成App闪退。

Demo

if ([[UIDevice currentDevice].systemVersion floatValue]>9.0) {
        
    //使用系统图标
    //UIApplicationShortcutIcon *icon1 = [UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypeShuffle];
    //使用自己的图片
    UIApplicationShortcutIcon *icon = [UIApplicationShortcutIcon iconWithTemplateImageName:@"2dCode"];
    UIApplicationShortcutItem *item1 = [[UIApplicationShortcutItem alloc]initWithType:@"item1" localizedTitle:@"二维码" localizedSubtitle:nil icon:icon userInfo:nil];
    
    NSArray *array = @[item1];
    [UIApplication sharedApplication].shortcutItems = array;

 }
//代理方法
-(void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler
{
    //这里可以实现界面跳转等方法
    if ([shortcutItem.type isEqualToString:@"item1"]) {
        NSLog(@"按压了第一个标题");
        NSDictionary *dic =  @{
                               @"page": @"WebController",
                               @"property": @{
                                       @"pUrl": WEB_ERWEIMA,
                                       }
                               };
        [LHPageJumperManager jump2Controller:dic popOther:NO];
    }
}
lADPBY0V4vY5eyfNBTbNAu4_750_1334.jpg_620x10000q90g.jpg

相关文章

网友评论

      本文标题:App图标上的3D_Touch

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