iOS 3D Touch开发

3D Touch 静态添加
静态添加是在plist文件中添加内容的方式添加3D Touch。

如图
也可以使用source code打开plist添加代码

<key>UIApplicationShortcutItems</key>
    <array>
        <dict>
            <key>UIApplicationShortcutItemIconFile</key>
            <string>setting_mor.png</string>
            <key>UIApplicationShortcutItemTitle</key>
            <string>设置</string>
            <key>UIApplicationShortcutItemType</key>
            <string>btn1</string>
        </dict>
    </array>

其中
UIApplicationShortcutItemTitle 标签的标题
UIApplicationShortcutItemType 标签的类型
这两项是必须设置的,
UIApplicationShortcutItemIconFile 图标文件
UIApplicationShortcutItemIconType 图表类型
UIApplicationShortcutItemSubtitle 副标题
UIApplicationShortcutItemUserInfo 信息字典
是可以选择设置的。
其中UIApplicationShortcutItemIconType的枚举为
typedef NS_ENUM(NSInteger, UIApplicationShortcutIconType) {
UIApplicationShortcutIconTypeCompose,//编辑的图标
UIApplicationShortcutIconTypePlay,//播放图标
UIApplicationShortcutIconTypePause,//暂停图标
UIApplicationShortcutIconTypeAdd,//添加图标
UIApplicationShortcutIconTypeLocation,//定位图标
UIApplicationShortcutIconTypeSearch,//搜索图标
UIApplicationShortcutIconTypeShare//分享图标
} NS_ENUM_AVAILABLE_IOS(9_0);
plist文件添加完成之后需要在AppDelegate.m中添加点击响应事件

- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void(^)(BOOL succeeded))completionHandler{
    //判断先前我们设置的唯一标识
    if([shortcutItem.type isEqualToString:@"btn1"]){
        FirstViewController *first = [[FirstViewController alloc] init];
        //设置当前的VC 为rootVC
        [self.window.rootViewController presentViewController:first animated:YES completion:^{
        }];
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值