swift开发笔记26 3D Touch
2018-01-02 09:30 dengchaojie_learner 阅读(210) 评论(0) 编辑 收藏 举报scale
3D Touch
// 定义一个枚举类型
enum Shortcut: String {
case openBlue = "OpenBlue"
}
// APP正在运行时,下面的方法会响应3D Touch操作
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
completionHandler(handleQuickAction(shortcutItem))
}
// guard
guard let touch = touches.first else {
return
}
// 判断3D Touch是否可用
if traitCollection.forceTouchCapability == UIForceTouchCapability.available {}