53
3D Touch Karol Kozub 2016-02-22

3D Touch by Karol Kozub, Macoscope

Embed Size (px)

Citation preview

Page 1: 3D Touch by Karol Kozub, Macoscope

3D TouchKarol Kozub 2016-02-22

Page 2: 3D Touch by Karol Kozub, Macoscope

The device senses how much pressure you apply to the display

Page 3: 3D Touch by Karol Kozub, Macoscope

“An entirely new way to interact with your phone”

Page 4: 3D Touch by Karol Kozub, Macoscope

UITouch.force

public class UITouch : NSObject {

// …

// Force of the touch, where 1.0 represents the force of an average touch public var force: CGFloat { get } // Maximum possible force with this input mechanism public var maximumPossibleForce: CGFloat { get }

// …

}

Page 5: 3D Touch by Karol Kozub, Macoscope

UITouch.force

public class UITouch : NSObject {

// …

// Force of the touch, where 1.0 represents the force of an average touch public var force: CGFloat { get } // Maximum possible force with this input mechanism public var maximumPossibleForce: CGFloat { get }

// …

}

For some reason equal to 6.66… on the iPhone 6s

Page 6: 3D Touch by Karol Kozub, Macoscope

UITouch.force

public class UITouch : NSObject {

// …

// Force of the touch, where 1.0 represents the force of an average touch public var force: CGFloat { get } // Maximum possible force with this input mechanism public var maximumPossibleForce: CGFloat { get }

// …

}

Page 7: 3D Touch by Karol Kozub, Macoscope

Quick Actions

Page 8: 3D Touch by Karol Kozub, Macoscope

• Apps can have up to 4 • Added either through Info.plist • Or dynamically in code

Quick Actions

Page 9: 3D Touch by Karol Kozub, Macoscope

Static Quick Actions

Page 10: 3D Touch by Karol Kozub, Macoscope

Static Quick Actions

Required

Page 11: 3D Touch by Karol Kozub, Macoscope

Static Quick Actions

Optional

Page 12: 3D Touch by Karol Kozub, Macoscope

Static Quick Actions

Type

Page 13: 3D Touch by Karol Kozub, Macoscope

Static Quick Actions

Title

Page 14: 3D Touch by Karol Kozub, Macoscope

Static Quick Actions

Subtitle

Page 15: 3D Touch by Karol Kozub, Macoscope

Static Quick Actions

Icon

Page 16: 3D Touch by Karol Kozub, Macoscope

Static Quick Actions

Icon

Page 17: 3D Touch by Karol Kozub, Macoscope

Static Quick Actions

User Info

Page 18: 3D Touch by Karol Kozub, Macoscope

System Icon TypesiOS 9.0

iOS 9.1

Page 19: 3D Touch by Karol Kozub, Macoscope

Dynamic Quick Actionsextension UIApplication { // Register shortcuts to display on the home screen, or retrieve currently registered shortcuts. @available(iOS 9.0, *) public var shortcutItems: [UIApplicationShortcutItem]? }

Page 20: 3D Touch by Karol Kozub, Macoscope

Dynamic Quick Actions

@available(iOS 9.0, *) public class UIApplicationShortcutItem : NSObject, NSCopying, NSMutableCopying {

public init(type: String, localizedTitle: String, localizedSubtitle: String?, icon: UIApplicationShortcutIcon?, userInfo: [NSObject : AnyObject]?) public convenience init(type: String, localizedTitle: String)

// An application-specific string that identifies the type of action to perform. public var type: String { get }

// Properties controlling how the item should be displayed on the home screen. public var localizedTitle: String { get } public var localizedSubtitle: String? { get } @NSCopying public var icon: UIApplicationShortcutIcon? { get }

// Application-specific information needed to perform the action. // Will throw an exception if the NSDictionary is not plist-encodable. public var userInfo: [String : NSSecureCoding]? { get } }

extension UIApplication { // Register shortcuts to display on the home screen, or retrieve currently registered shortcuts. @available(iOS 9.0, *) public var shortcutItems: [UIApplicationShortcutItem]? }

Page 21: 3D Touch by Karol Kozub, Macoscope

Dynamic Quick Actions

@available(iOS 9.0, *) public class UIApplicationShortcutItem : NSObject, NSCopying, NSMutableCopying {

public init(type: String, localizedTitle: String, localizedSubtitle: String?, icon: UIApplicationShortcutIcon?, userInfo: [NSObject : AnyObject]?) public convenience init(type: String, localizedTitle: String)

// An application-specific string that identifies the type of action to perform. public var type: String { get }

// Properties controlling how the item should be displayed on the home screen. public var localizedTitle: String { get } public var localizedSubtitle: String? { get } @NSCopying public var icon: UIApplicationShortcutIcon? { get }

// Application-specific information needed to perform the action. // Will throw an exception if the NSDictionary is not plist-encodable. public var userInfo: [String : NSSecureCoding]? { get } }

extension UIApplication { // Register shortcuts to display on the home screen, or retrieve currently registered shortcuts. @available(iOS 9.0, *) public var shortcutItems: [UIApplicationShortcutItem]? }

Required

Optional

Page 22: 3D Touch by Karol Kozub, Macoscope

Dynamic Quick Actions let iconTypeIcon = UIApplicationShortcutIcon(type: .Search) let iconTypeItem = UIApplicationShortcutItem(type: "icon-type-item", localizedTitle: "Search", localizedSubtitle: "icon from an icon type", icon: iconTypeIcon, userInfo: nil)

let templateIcon = UIApplicationShortcutIcon(templateImageName: "triangle") let templateItem = UIApplicationShortcutItem(type: "template-item", localizedTitle: "Triangle", localizedSubtitle: "icon from template image", icon: templateIcon, userInfo: nil)

let contactStoreContactIcon = UIApplicationShortcutIcon(contact: contactFromContactStore) let contactStoreContactItem = UIApplicationShortcutItem(type: "real-contact-item", localizedTitle: "Karol", localizedSubtitle: "icon from real contact", icon: contactStoreContactIcon, userInfo: nil)

let temporaryContact = CNMutableContact() temporaryContact.givenName = "Hiro"; temporaryContact.familyName = "Protagonist";

// this will be ignored temporaryContact.imageData = UIImagePNGRepresentation(UIImage(named: "triangle")!)

let temporaryContactIcon = UIApplicationShortcutIcon(contact: temporaryContact) let temporaryContactItem = UIApplicationShortcutItem(type: "temporary-contact-item", localizedTitle: "Hiro", localizedSubtitle: "icon from tmp contact", icon: temporaryContactIcon, userInfo: nil)

UIApplication.sharedApplication().shortcutItems = [iconTypeItem, templateItem, contactStoreContactItem, temporaryContactItem]

Page 23: 3D Touch by Karol Kozub, Macoscope

Dynamic Quick Actions let iconTypeIcon = UIApplicationShortcutIcon(type: .Search) let iconTypeItem = UIApplicationShortcutItem(type: "icon-type-item", localizedTitle: "Search", localizedSubtitle: "icon from an icon type", icon: iconTypeIcon, userInfo: nil)

let templateIcon = UIApplicationShortcutIcon(templateImageName: "triangle") let templateItem = UIApplicationShortcutItem(type: "template-item", localizedTitle: "Triangle", localizedSubtitle: "icon from template image", icon: templateIcon, userInfo: nil)

let contactStoreContactIcon = UIApplicationShortcutIcon(contact: contactFromContactStore) let contactStoreContactItem = UIApplicationShortcutItem(type: "real-contact-item", localizedTitle: "Karol", localizedSubtitle: "icon from real contact", icon: contactStoreContactIcon, userInfo: nil)

let temporaryContact = CNMutableContact() temporaryContact.givenName = "Hiro"; temporaryContact.familyName = "Protagonist";

// this will be ignored temporaryContact.imageData = UIImagePNGRepresentation(UIImage(named: "triangle")!)

let temporaryContactIcon = UIApplicationShortcutIcon(contact: temporaryContact) let temporaryContactItem = UIApplicationShortcutItem(type: "temporary-contact-item", localizedTitle: "Hiro", localizedSubtitle: "icon from tmp contact", icon: temporaryContactIcon, userInfo: nil)

UIApplication.sharedApplication().shortcutItems = [iconTypeItem, templateItem, contactStoreContactItem, temporaryContactItem]

Page 24: 3D Touch by Karol Kozub, Macoscope

Dynamic Quick Actions let iconTypeIcon = UIApplicationShortcutIcon(type: .Search) let iconTypeItem = UIApplicationShortcutItem(type: "icon-type-item", localizedTitle: "Search", localizedSubtitle: "icon from an icon type", icon: iconTypeIcon, userInfo: nil)

let templateIcon = UIApplicationShortcutIcon(templateImageName: "triangle") let templateItem = UIApplicationShortcutItem(type: "template-item", localizedTitle: "Triangle", localizedSubtitle: "icon from template image", icon: templateIcon, userInfo: nil)

let contactStoreContactIcon = UIApplicationShortcutIcon(contact: contactFromContactStore) let contactStoreContactItem = UIApplicationShortcutItem(type: "real-contact-item", localizedTitle: "Karol", localizedSubtitle: "icon from real contact", icon: contactStoreContactIcon, userInfo: nil)

let temporaryContact = CNMutableContact() temporaryContact.givenName = "Hiro"; temporaryContact.familyName = "Protagonist";

// this will be ignored temporaryContact.imageData = UIImagePNGRepresentation(UIImage(named: "triangle")!)

let temporaryContactIcon = UIApplicationShortcutIcon(contact: temporaryContact) let temporaryContactItem = UIApplicationShortcutItem(type: "temporary-contact-item", localizedTitle: "Hiro", localizedSubtitle: "icon from tmp contact", icon: temporaryContactIcon, userInfo: nil)

UIApplication.sharedApplication().shortcutItems = [iconTypeItem, templateItem, contactStoreContactItem, temporaryContactItem]

Page 25: 3D Touch by Karol Kozub, Macoscope

Dynamic Quick Actions let iconTypeIcon = UIApplicationShortcutIcon(type: .Search) let iconTypeItem = UIApplicationShortcutItem(type: "icon-type-item", localizedTitle: "Search", localizedSubtitle: "icon from an icon type", icon: iconTypeIcon, userInfo: nil)

let templateIcon = UIApplicationShortcutIcon(templateImageName: "triangle") let templateItem = UIApplicationShortcutItem(type: "template-item", localizedTitle: "Triangle", localizedSubtitle: "icon from template image", icon: templateIcon, userInfo: nil)

let contactStoreContactIcon = UIApplicationShortcutIcon(contact: contactFromContactStore) let contactStoreContactItem = UIApplicationShortcutItem(type: "real-contact-item", localizedTitle: "Karol", localizedSubtitle: "icon from real contact", icon: contactStoreContactIcon, userInfo: nil)

let temporaryContact = CNMutableContact() temporaryContact.givenName = "Hiro"; temporaryContact.familyName = "Protagonist";

// this will be ignored temporaryContact.imageData = UIImagePNGRepresentation(UIImage(named: "triangle")!)

let temporaryContactIcon = UIApplicationShortcutIcon(contact: temporaryContact) let temporaryContactItem = UIApplicationShortcutItem(type: "temporary-contact-item", localizedTitle: "Hiro", localizedSubtitle: "icon from tmp contact", icon: temporaryContactIcon, userInfo: nil)

UIApplication.sharedApplication().shortcutItems = [iconTypeItem, templateItem, contactStoreContactItem, temporaryContactItem]

Page 26: 3D Touch by Karol Kozub, Macoscope

Dynamic Quick Actions let iconTypeIcon = UIApplicationShortcutIcon(type: .Search) let iconTypeItem = UIApplicationShortcutItem(type: "icon-type-item", localizedTitle: "Search", localizedSubtitle: "icon from an icon type", icon: iconTypeIcon, userInfo: nil)

let templateIcon = UIApplicationShortcutIcon(templateImageName: "triangle") let templateItem = UIApplicationShortcutItem(type: "template-item", localizedTitle: "Triangle", localizedSubtitle: "icon from template image", icon: templateIcon, userInfo: nil)

let contactStoreContactIcon = UIApplicationShortcutIcon(contact: contactFromContactStore) let contactStoreContactItem = UIApplicationShortcutItem(type: "real-contact-item", localizedTitle: "Karol", localizedSubtitle: "icon from real contact", icon: contactStoreContactIcon, userInfo: nil)

let temporaryContact = CNMutableContact() temporaryContact.givenName = "Hiro"; temporaryContact.familyName = "Protagonist";

// this will be ignored temporaryContact.imageData = UIImagePNGRepresentation(UIImage(named: "triangle")!)

let temporaryContactIcon = UIApplicationShortcutIcon(contact: temporaryContact) let temporaryContactItem = UIApplicationShortcutItem(type: "temporary-contact-item", localizedTitle: "Hiro", localizedSubtitle: "icon from tmp contact", icon: temporaryContactIcon, userInfo: nil)

UIApplication.sharedApplication().shortcutItems = [iconTypeItem, templateItem, contactStoreContactItem, temporaryContactItem]

Page 27: 3D Touch by Karol Kozub, Macoscope

Dynamic Quick Actions let iconTypeIcon = UIApplicationShortcutIcon(type: .Search) let iconTypeItem = UIApplicationShortcutItem(type: "icon-type-item", localizedTitle: "Search", localizedSubtitle: "icon from an icon type", icon: iconTypeIcon, userInfo: nil)

let templateIcon = UIApplicationShortcutIcon(templateImageName: "triangle") let templateItem = UIApplicationShortcutItem(type: "template-item", localizedTitle: "Triangle", localizedSubtitle: "icon from template image", icon: templateIcon, userInfo: nil)

let contactStoreContactIcon = UIApplicationShortcutIcon(contact: contactFromContactStore) let contactStoreContactItem = UIApplicationShortcutItem(type: "real-contact-item", localizedTitle: "Karol", localizedSubtitle: "icon from real contact", icon: contactStoreContactIcon, userInfo: nil)

let temporaryContact = CNMutableContact() temporaryContact.givenName = "Hiro"; temporaryContact.familyName = "Protagonist";

// this will be ignored temporaryContact.imageData = UIImagePNGRepresentation(UIImage(named: "triangle")!)

let temporaryContactIcon = UIApplicationShortcutIcon(contact: temporaryContact) let temporaryContactItem = UIApplicationShortcutItem(type: "temporary-contact-item", localizedTitle: "Hiro", localizedSubtitle: "icon from tmp contact", icon: temporaryContactIcon, userInfo: nil)

UIApplication.sharedApplication().shortcutItems = [iconTypeItem, templateItem, contactStoreContactItem, temporaryContactItem]

Page 28: 3D Touch by Karol Kozub, Macoscope

Handling Quick Actions

public protocol UIApplicationDelegate : NSObjectProtocol {

// …

// Called when the user activates your application by // selecting a shortcut on the home screen, // except when -application:willFinishLaunchingWithOptions: or // -application:didFinishLaunchingWithOptions returns NO. @available(iOS 9.0, *) optional public func application(application: UIApplication, performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: (Bool) -> Void) // …

}

Page 29: 3D Touch by Karol Kozub, Macoscope

Handling Quick Actions

public protocol UIApplicationDelegate : NSObjectProtocol {

// …

// Called when the user activates your application by // selecting a shortcut on the home screen, // except when -application:willFinishLaunchingWithOptions: or // -application:didFinishLaunchingWithOptions returns NO. @available(iOS 9.0, *) optional public func application(application: UIApplication, performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: (Bool) -> Void) // …

}

Full-blown shortcut item

Page 30: 3D Touch by Karol Kozub, Macoscope

Handling Quick Actions

public protocol UIApplicationDelegate : NSObjectProtocol {

// …

// Called when the user activates your application by // selecting a shortcut on the home screen, // except when -application:willFinishLaunchingWithOptions: or // -application:didFinishLaunchingWithOptions returns NO. @available(iOS 9.0, *) optional public func application(application: UIApplication, performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: (Bool) -> Void) // …

}

Call when finished

Page 31: 3D Touch by Karol Kozub, Macoscope

Peek and Pop

Page 32: 3D Touch by Karol Kozub, Macoscope

• Press to Peek at what’s inside • Stop pressing to hide the preview • Press harder to Pop into the view

Peek and Pop

Page 33: 3D Touch by Karol Kozub, Macoscope

Peek and Popextension UIViewController {

// Registers a view controller to participate with 3D Touch preview (peek) and commit (pop). @available(iOS 9.0, *) public func registerForPreviewingWithDelegate(delegate: UIViewControllerPreviewingDelegate, sourceView: UIView) -> UIViewControllerPreviewing @available(iOS 9.0, *) public func unregisterForPreviewingWithContext(previewing: UIViewControllerPreviewing) }

@available(iOS 9.0, *) public protocol UIViewControllerPreviewingDelegate : NSObjectProtocol {

// If you return nil, a preview presentation will not be performed @available(iOS 9.0, *) public func previewingContext(previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? @available(iOS 9.0, *) public func previewingContext(previewingContext: UIViewControllerPreviewing, commitViewController viewControllerToCommit: UIViewController) }

Page 34: 3D Touch by Karol Kozub, Macoscope

Peek and Popclass ViewController: UIViewController, UIViewControllerPreviewingDelegate { @IBOutlet weak var sourceView: UIView!

override func viewDidLoad() { super.viewDidLoad() registerForPreviewingWithDelegate(self, sourceView: sourceView) }

func previewingContext(previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? { return PreviewedViewController() }

func previewingContext(previewingContext: UIViewControllerPreviewing, commitViewController viewControllerToCommit: UIViewController) { navigationController?.pushViewController(viewControllerToCommit, animated: false) } }

Page 35: 3D Touch by Karol Kozub, Macoscope

Peek and Pop

class ViewController: UIViewController, UIViewControllerPreviewingDelegate { @IBOutlet weak var sourceView: UIView!

override func viewDidLoad() { super.viewDidLoad() registerForPreviewingWithDelegate(self, sourceView: sourceView) }

func previewingContext(previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? { return PreviewedViewController() }

func previewingContext(previewingContext: UIViewControllerPreviewing, commitViewController viewControllerToCommit: UIViewController) { navigationController?.pushViewController(viewControllerToCommit, animated: false) } }

Page 36: 3D Touch by Karol Kozub, Macoscope

Peek and Poppublic protocol UIViewControllerPreviewing : NSObjectProtocol {

// This gesture can be used to cause the previewing presentation // to wait until one of your gestures fails or to allow simultaneous // recognition during the initial phase of the preview presentation. @available(iOS 9.0, *) public var previewingGestureRecognizerForFailureRelationship: UIGestureRecognizer { get }

@available(iOS 9.0, *) public var delegate: UIViewControllerPreviewingDelegate { get } @available(iOS 9.0, *) public var sourceView: UIView { get }

// This rect will be set to the bounds of sourceView before each call to // -previewingContext:viewControllerForLocation:

@available(iOS 9.0, *) public var sourceRect: CGRect { get set } }

Page 37: 3D Touch by Karol Kozub, Macoscope

Peek and Popclass ViewController: UIViewController, UIViewControllerPreviewingDelegate { @IBOutlet weak var sourceView: UIView!

override func viewDidLoad() { super.viewDidLoad() registerForPreviewingWithDelegate(self, sourceView: sourceView) }

func previewingContext(previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? { let rect = CGRectInset(previewingContext.sourceView.bounds, 20, 20) previewingContext.sourceRect = rect

return PreviewedViewController() }

func previewingContext(previewingContext: UIViewControllerPreviewing, commitViewController viewControllerToCommit: UIViewController) { navigationController?.pushViewController(viewControllerToCommit, animated: false) } }

Page 38: 3D Touch by Karol Kozub, Macoscope

Peek and Pop

class ViewController: UIViewController, UIViewControllerPreviewingDelegate { @IBOutlet weak var sourceView: UIView!

override func viewDidLoad() { super.viewDidLoad() registerForPreviewingWithDelegate(self, sourceView: sourceView) }

func previewingContext(previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? { return nil }

func previewingContext(previewingContext: UIViewControllerPreviewing, commitViewController viewControllerToCommit: UIViewController) { navigationController?.pushViewController(viewControllerToCommit, animated: false) } }

Page 39: 3D Touch by Karol Kozub, Macoscope

Peek Quick Actionsextension UIViewController { public func previewActionItems() -> [UIPreviewActionItem] }

public protocol UIPreviewActionItem : NSObjectProtocol { public var title: String { get } }

public class UIPreviewAction : NSObject, NSCopying, UIPreviewActionItem { public var handler: (UIPreviewActionItem, UIViewController) -> Void { get }

public convenience init(title: String, style: UIPreviewActionStyle, handler: (UIPreviewAction, UIViewController) -> Void) }

public class UIPreviewActionGroup : NSObject, NSCopying, UIPreviewActionItem { public convenience init(title: String, style: UIPreviewActionStyle, actions: [UIPreviewAction]) }

Page 40: 3D Touch by Karol Kozub, Macoscope

Peek Quick Actionsextension UIViewController { public func previewActionItems() -> [UIPreviewActionItem] }

public protocol UIPreviewActionItem : NSObjectProtocol { public var title: String { get } }

public class UIPreviewAction : NSObject, NSCopying, UIPreviewActionItem { public var handler: (UIPreviewActionItem, UIViewController) -> Void { get }

public convenience init(title: String, style: UIPreviewActionStyle, handler: (UIPreviewAction, UIViewController) -> Void) }

public class UIPreviewActionGroup : NSObject, NSCopying, UIPreviewActionItem { public convenience init(title: String, style: UIPreviewActionStyle, actions: [UIPreviewAction]) }

Page 41: 3D Touch by Karol Kozub, Macoscope

Peek Quick Actionsextension UIViewController { public func previewActionItems() -> [UIPreviewActionItem] }

public protocol UIPreviewActionItem : NSObjectProtocol { public var title: String { get } }

public class UIPreviewAction : NSObject, NSCopying, UIPreviewActionItem { public var handler: (UIPreviewActionItem, UIViewController) -> Void { get }

public convenience init(title: String, style: UIPreviewActionStyle, handler: (UIPreviewAction, UIViewController) -> Void) }

public class UIPreviewActionGroup : NSObject, NSCopying, UIPreviewActionItem { public convenience init(title: String, style: UIPreviewActionStyle, actions: [UIPreviewAction]) }

Page 42: 3D Touch by Karol Kozub, Macoscope

Peek Quick Actions

class PreviewedViewController: UIViewController { override func previewActionItems() -> [UIPreviewActionItem] { let defaultStyleAction = UIPreviewAction(title: "Default Style", style: .Default) {action, controller in }

let destructiveStyleAction = UIPreviewAction(title: "Destructive Style", style: .Destructive) {action, controller in }

let selectedStyleAction = UIPreviewAction(title: "Selected Style", style: .Selected) {action, controller in }

let actionGroup = UIPreviewActionGroup(title: "Group", style: .Default, actions: [defaultStyleAction, defaultStyleAction, defaultStyleAction])

return [defaultStyleAction, destructiveStyleAction, selectedStyleAction, actionGroup] } }

Page 43: 3D Touch by Karol Kozub, Macoscope

Peek Quick Actionsclass PreviewedViewController: UIViewController { override func previewActionItems() -> [UIPreviewActionItem] { let defaultStyleAction = UIPreviewAction(title: "Default Style", style: .Default) {action, controller in }

let destructiveStyleAction = UIPreviewAction(title: "Destructive Style", style: .Destructive) {action, controller in }

let selectedStyleAction = UIPreviewAction(title: "Selected Style", style: .Selected) {action, controller in }

return [defaultStyleAction, destructiveStyleAction, selectedStyleAction, defaultStyleAction, destructiveStyleAction, selectedStyleAction, defaultStyleAction, destructiveStyleAction, selectedStyleAction, defaultStyleAction, destructiveStyleAction, selectedStyleAction, defaultStyleAction, destructiveStyleAction, selectedStyleAction, defaultStyleAction, destructiveStyleAction, selectedStyleAction, defaultStyleAction, destructiveStyleAction, selectedStyleAction, defaultStyleAction, destructiveStyleAction, selectedStyleAction, defaultStyleAction, destructiveStyleAction, selectedStyleAction, defaultStyleAction, destructiveStyleAction, selectedStyleAction] } }

Page 44: 3D Touch by Karol Kozub, Macoscope

Detecting 3D Touchpublic class UITraitCollection : NSObject, NSCopying, NSSecureCoding { // …

public var forceTouchCapability: UIForceTouchCapability { get }

// … }

public enum UIForceTouchCapability : Int { case Unknown case Unavailable case Available }

Page 45: 3D Touch by Karol Kozub, Macoscope

Detecting 3D Touchpublic class UITraitCollection : NSObject, NSCopying, NSSecureCoding { // …

public var forceTouchCapability: UIForceTouchCapability { get }

// … }

public enum UIForceTouchCapability : Int { case Unknown case Unavailable case Available }

/*! Trait environments expose a trait collection that describes their environment. */ public protocol UITraitEnvironment : NSObjectProtocol { public var traitCollection: UITraitCollection { get } /*! To be overridden as needed to provide custom behavior when the environment's traits change. */ public func traitCollectionDidChange(previousTraitCollection: UITraitCollection?) }

Page 46: 3D Touch by Karol Kozub, Macoscope

Detecting 3D Touchpublic class UITraitCollection : NSObject, NSCopying, NSSecureCoding { // …

public var forceTouchCapability: UIForceTouchCapability { get }

// … }

public enum UIForceTouchCapability : Int { case Unknown case Unavailable case Available }

/*! Trait environments expose a trait collection that describes their environment. */ public protocol UITraitEnvironment : NSObjectProtocol { public var traitCollection: UITraitCollection { get } /*! To be overridden as needed to provide custom behavior when the environment's traits change. */ public func traitCollectionDidChange(previousTraitCollection: UITraitCollection?) }

The following interface classes adopt this protocol: UIScreen, UIWindow, UIViewController, UIPresentationController, and UIView.

Page 47: 3D Touch by Karol Kozub, Macoscope

Summary• UITouch.force

• Static Quick Actions

• Dynamic Quick Actions

• Peek and Pop

• Peek Quick Actions

• Detecting 3D Touch

Page 48: 3D Touch by Karol Kozub, Macoscope

Summary• UITouch.force

• Static Quick Actions

• Dynamic Quick Actions

• Peek and Pop

• Peek Quick Actions

• Detecting 3D Touch

Page 49: 3D Touch by Karol Kozub, Macoscope

Summary• UITouch.force

• Static Quick Actions

• Dynamic Quick Actions

• Peek and Pop

• Peek Quick Actions

• Detecting 3D Touch

Page 50: 3D Touch by Karol Kozub, Macoscope

Summary• UITouch.force

• Static Quick Actions

• Dynamic Quick Actions

• Peek and Pop

• Peek Quick Actions

• Detecting 3D Touch

Page 51: 3D Touch by Karol Kozub, Macoscope

Summary• UITouch.force

• Static Quick Actions

• Dynamic Quick Actions

• Peek and Pop

• Peek Quick Actions

• Detecting 3D Touch

Page 52: 3D Touch by Karol Kozub, Macoscope

Summary• UITouch.force

• Static Quick Actions

• Dynamic Quick Actions

• Peek and Pop

• Peek Quick Actions

• Detecting 3D Touch

Page 53: 3D Touch by Karol Kozub, Macoscope

Thank you for listening