iOS 3D Touch开发

来源:互联网 发布:淘宝十月份活动 编辑:程序博客网 时间:2024/05/10 05:13

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:^{        }];    }}
0 0
原创粉丝点击