To run the example project, clone the repo, and run pod install
from the Example directory first.
ForceTouchable is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "ForceTouchable"
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)
}
}
Ivan Bruel, [email protected]
ForceTouchable is available under the MIT license. See the LICENSE file for more info.