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

cockscomb

July 11, 2015
Tweet

More Decks by cockscomb

Other Decks in Programming

Transcript

  1. 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) } }
  2. 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) } }
  3. 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)") } } }
  4. NSEvent • NSEventTypePressure • var pressure: Float { get }

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

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

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