3dtouch to present(peek without pop) UIView like contacts app
Asked Answered
A

1

12

I'm trying to implement 3D Touch feature that presents a summary of information (like Peek). But I don't want that it pops. I just want to preview the information like contacts app does with contatcs:

enter image description here

It only presents an UIView and doesn't deal with two levels of force (peek and pop).

How can I do something like this?

Ps.: I don't want to deal with long press gesture.

Abstract answered 23/3, 2016 at 15:5 Comment(2)
Did you ever find a solution for this?Anapest
No. You can't do this. Its a native behaviour for contacts.Abstract
S
0

Introduction

Hello

I know this is a bit to late, probably, but in case someone else stumbles upon it: I certainly believe it is possible and I don't think its a "native behavior for contacts". Although it would not be as simple as the UIKit api for peek pop views. You would need to:

Steps

  1. subclass UIGestureRecognizer (perhaps it may work with the UITapGestureRecognizer also), and register UITouches and use their force property.

  2. Setup a UIViewController with transparent but blurred background around the edges (together with a modalPresentationStyle .overCurrentContext if i recall correctly), with your desired content in the middle (much like the peek view). Then add a UIPanGestureRecognizer to the center view for dismissal/sliding up the buttons.

  3. And then create a custom animation transition for that UIViewController to be triggered once the force property of the registered UITouches from the subclassed UIGestureRecognizer is high enough. And then reversed once the force property gets low enough.

Concluding notes

I believe this is a bit of a tedious task and there might be a simpler way. For example, a simpler way using a 3rd party library for long pressure gestures (that registers size of the touch), but it would not give the same feel.

Stonyhearted answered 14/12, 2018 at 17:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.