ForceTouchable 1.0.2

ForceTouchable 1.0.2

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Apr 2016
SPMSupports SPM

Maintained by Ivan Bruel.



ForceTouchable

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

ForceTouchable is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "ForceTouchable"

Usage

To use ForceTouchable on your UIViewControllers all you have to do is implement the ForceTouchable protocol. Most methods are already implemented in case your ForceTouchable implementation is a UIViewController, all you need to implement is forceTouchPreviewForLocation(CGPoint) and call setupForceTouch() on your viewDidAppear method.

// MARK: ForceTouchable
extension ViewController: ForceTouchable {

  override func viewDidAppear(animated: Bool) {
    super.viewDidAppear(animated)
    setupForceTouch()
  }

  func forceTouchPreviewForLocation(location: CGPoint) -> ForceTouchPreview? {
    guard let indexPath = tableView.indexPathForRowAtPoint(location),
      cell = tableView.cellForRowAtIndexPath(indexPath) else { return nil }

    // Create a detail view controller and set its properties.
    guard let detailViewController = storyboard?.instantiateViewControllerWithIdentifier("DetailViewController") as? DetailViewController else { return nil }

    let previewDetail = sampleData[indexPath.row]
    detailViewController.detailItemTitle = previewDetail.title

    return ForceTouchPreview(previewViewController: detailViewController, touchedView: cell)
  }

}

Author

Ivan Bruel, [email protected]

License

ForceTouchable is available under the MIT license. See the LICENSE file for more info.