Option Prompt on Button Hold

So I want to implement the same feature many apple made have which is an gray list of options when something is held. An example of this is when you hold down an iMessage chat before you open it and it gives the options to “Pin”, “Hide Alerts”, and “Delete” and shown here:

Additionally when you hold down an app as if you were going to delete it a menu of options show up:

Using a button how can I do this on a long hold? Any help or any direction toward help is greatly appreciated. All the best!

Answered by coder3131 in 714893022

This is called a context menu. To implement it, you need to add

.contextMenu {
   // Add whatever you want here... including buttons or text
}

to your button, but it can also work with any other view.

Accepted Answer

This is called a context menu. To implement it, you need to add

.contextMenu {
   // Add whatever you want here... including buttons or text
}

to your button, but it can also work with any other view.

Option Prompt on Button Hold
 
 
Q