Skip to content

Latest commit

 

History

History
58 lines (38 loc) · 2 KB

README.md

File metadata and controls

58 lines (38 loc) · 2 KB

ForceTouchable

Version License Platform

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.