1. 程式人生 > >Bringing Peek and Pop to all iOS users

Bringing Peek and Pop to all iOS users

Bringing Peek and Pop to all iOS users

Introducing PeekPop

With the iPhone 6S and 6S+, Apple introduced us to 3D Touch — a whole new way for your iPhone to sense pressure on the screen. One of the coolest features employing 3D touch was Peek and Pop. When you press softly on a view, you get what’s called a Peek

 — a pop-up preview of the next bit of content. Press more, and you Pop it to fill the screen. When implemented well, this is an incredibly powerful paradigm.

The only downside of Peek and Pop is that it’s only available on the two latest iPhones and 80% of the world is currently running older devices (yours truly included). Why can’t we get to enjoy this cool new way to preview content?

Hello PeekPop

PeekPop is a new Swift framework aiming to bring backwards compatibility to peeking and popping. On devices that are 3D touch capable, PeekPop uses Apple’s native 3D touch implementation. On older devices, it uses a faithful recreation of the feature. PeekPop ships with a gesture recognizer that senses pressure by observing changes in the surface area of the touch (assuming that when pressing harder on the screen, more of the finger is in contact with it). It works surprisingly well. Here it is running on iOS8:

Not too shabby…

PeekPop was developed with the objective of staying as close to Apple’s previewing API so implementing it stays super simple:

The one missing feature currently is supporting UIPreviewActions on devices that don’t have 3D touch.

That will come soon…

Check it out on: