I have built a library to use as an alternative for devices without 3D Touch. My demo project also demonstrates how the project can support both types of devices. You can try it here: PeekView
The usage is pretty simple:
- Add UILongPressGestureRecognizer to the view you want to peek (i.e
table view cell, image, hypertext, etc.)
- Create a UIViewController
instance as the content of your peek view; then set your desired frame
for the content view. It's recommended to leave a 15px padding for
both left and right margin of your content view.
- If you want to
include preview actions, prepare an array containing title of the
buttons and its preview style. Don't forget to prepare completion
handlers for when each button is tapped.
Sample snippet:
PeekView.viewForController(
parentViewController: self,
contentViewController: controller,
expectedContentViewFrame: frame,
fromGesture: gestureRecognizer,
shouldHideStatusBar: true,
withOptions: ["Option 1": .Destructive, "Option 2": .Default, "Option 3": .Selected],
completionHandler: { optionIndex in
switch optionIndex {
case 0:
print("Option 1 selected")
case 1:
print("Option 2 selected")
case 2:
print("Option 3 selected")
default:
break
}
})
Preview:
