IOS 3Dtouch
2015-09-30 17:24
417 查看
https://github.com/itjhDev/itjh_3DTouch
项目地址:https://github.com/DeskConnect/SBShortcutMenuSimulator.git
icon 重按弹出菜单
tableView Cell 轻按按预览文章详情
tableView Cell 轻按按预览文章详情,上滑底部显示Action
tableView Cell 轻按按预览文章详情,重按进入文章详情页
完整的3D Touch 动画视频
在
更多代码查看
昨天闲来无事,对着自己的iPhone6s,准备给IT江湖加入3D Touch吧!!
没有6s的 模拟器也可以测试,按照@conradev 的SBShortcutMenuSimulator测试项目地址:https://github.com/DeskConnect/SBShortcutMenuSimulator.git
icon 重按弹出菜单
tableView Cell 轻按按预览文章详情
tableView Cell 轻按按预览文章详情,上滑底部显示Action
tableView Cell 轻按按预览文章详情,重按进入文章详情页
效果图
完整的3D Touch 动画视频
icon 重按弹出菜单
代码片段:在
AppleDelegate文件中
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. //添加icon 3d Touch let firstItemIcon:UIApplicationShortcutIcon = UIApplicationShortcutIcon(type: .Share) let firstItem = UIMutableApplicationShortcutItem(type: "1", localizedTitle: "分享", localizedSubtitle: nil, icon: firstItemIcon, userInfo: nil) let firstItemIcon1:UIApplicationShortcutIcon = UIApplicationShortcutIcon(type: .Compose) let firstItem1 = UIMutableApplicationShortcutItem(type: "2", localizedTitle: "编辑", localizedSubtitle: nil, icon: firstItemIcon1, userInfo: nil) application.shortcutItems = [firstItem,firstItem1] return true } /** 3D Touch 跳转 - parameter application: application - parameter shortcutItem: item - parameter completionHandler: handler */ func application(application: UIApplication, performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: (Bool) -> Void) { let handledShortCutItem = handleShortCutItem(shortcutItem) completionHandler(handledShortCutItem) } func handleShortCutItem(shortcutItem: UIApplicationShortcutItem) -> Bool { var handled = false if shortcutItem.type == "1" { //分享 let rootNavigationViewController = window!.rootViewController as? UINavigationController let rootViewController = rootNavigationViewController?.viewControllers.first as UIViewController? rootNavigationViewController?.popToRootViewControllerAnimated(false) rootViewController?.performSegueWithIdentifier("toShare", sender: nil) handled = true } if shortcutItem.type == "2" { //编辑 let rootNavigationViewController = window!.rootViewController as? UINavigationController let rootViewController = rootNavigationViewController?.viewControllers.first as UIViewController? rootNavigationViewController?.popToRootViewControllerAnimated(false) rootViewController?.performSegueWithIdentifier("toCompose", sender: nil) handled = true } return handled }
tableView Cell 轻按按预览文章详情
代码片段:func previewingContext(previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? { let cellPosition = tableView.convertPoint(location, fromView: view) if let touchedIndexPath = tableView.indexPathForRowAtPoint(cellPosition) { tableView.deselectRowAtIndexPath(touchedIndexPath, animated: true) let aStoryboard = UIStoryboard(name: "Main", bundle:NSBundle.mainBundle()) if let myVC = aStoryboard.instantiateViewControllerWithIdentifier("ArtilceShowView") as? ArticleShowViewController { myVC.urlStr = "https://www.baidu.com" let cellFrame = tableView.cellForRowAtIndexPath(touchedIndexPath)!.frame previewingContext.sourceRect = view.convertRect(cellFrame, fromView: tableView) return myVC } } return UIViewController() }
更多代码查看
ArticlesTableViewController文件
相关文章推荐
- iOS 9适配技巧(更新版)
- iOS开发之 转场动画CATransition
- 关于iOS的自动弹出键盘问题
- 整理iOS9适配中出现的坑
- 获取当前日期、时间--iOS开发
- iOS开发之 动画组CAAnimationGroup
- iOS 8创建交互式通知
- [iOS]Core Data
- 如何才能系统的学习 iOS 开发,理解一些规则和深层次的机制原理?
- xcode7编译ios9 报错
- iOS开发之 关键帧动画
- iOS中使用模板引擎渲染HTML界面
- ios环境下Axure的安装
- iOS中容易出错的问题
- iOS开发文档(中文)
- ios中frame设置宽高计算的Demo
- 自己整理的iOS代码编写规范
- iOS 原生态API实现二维码的扫描功能
- 总结分享十大iOS开发者最喜爱的库
- 介绍一个轻量级iOS安全框架:SSKeyChain