Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Force Touch APIs in OS X

Force Touch APIs in OS X

Presented at Cocoa勉強会関西62

58b40ae3b0db6cf0202a3802e9dd70fe?s=128

cockscomb

July 11, 2015
Tweet

Transcript

  1. Force Touch The New Dimension

  2. cockscomb

  3. None
  4. Force Touch The New Dimension

  5. Force Touch Trackpad

  6. Force Touch APIs

  7. None
  8. NSButton • func setButtonType(_ aType: NSButtonType) • NSAcceleratorButton • NSMultiLevelAcceleratorButton

  9. NSAcceleratorButton @IBOutlet weak var acceleratorButton: NSButton! { didSet { acceleratorButton.continuous

    = true acceleratorButton .setPeriodicDelay(0.1, interval: 0.1) } } @IBAction func accelerate(sender: AnyObject) { if let button = sender as? NSButton { print(button.doubleValue) } }
  10. NSMultiLevelAcceleratorButton @IBOutlet weak var multiLevelAcceratorButton: NSButton! { didSet { if

    #available(OSX 10.10.3, *) { multiLevelAcceratorButton .maxAcceleratorLevel = 5 } } } @IBAction func multiLevelAccelerate(sender: AnyObject) { if let button = sender as? NSButton { print(button.integerValue) } }
  11. NSButton • NSAcceleratorButton • doubleValue • 0.0, 1.0..<2.0 • NSMultiLevelAcceleratorButton

    • integerValue • 0, 1, 2..<maxAcceleratorLevel
  12. NSEvent • NSView • NSGestureRecognizer • NSWindow

  13. NSEventTypePressure class PressureView: NSView { override func pressureChangeWithEvent(event: NSEvent) {

    Swift.print("Pressure : \(event.pressure)") if #available(OSX 10.10.3, *) { Swift.print("Stage : \(event.stage)") Swift.print(“State Transition : \(event.stageTransition)") } } }
  14. NSEvent • NSEventTypePressure • var pressure: Float { get }

    • Pressure value • var stage: Int { get } • Pressed stage • var stageTransition: CGFloat { get } • For transition animation
  15. El Capitan • NSAlignmentFeedbackFilter • Sample Code: AlignmentGuides • NSHapticFeedbackManager

    • enum NSHapticFeedbackPattern • Generic/Alignment/LevelChange • And more…
  16. Force Touch • A new dimension of the UI •

    APIs are available (improved with El Capitan) • Will be introduced into iOS 9?