How to use ContextMenu in SwifUI | Bootcamp #34

preview_player
Показать описание
In this video we will learn how to use and implement a .contextMenu into our SwiftUI application. The Context Menu is a relatively new features in iOS that presents a menu of buttons to our user on top of an object. While the ContextMenu is not as popular as some of the other components we've learned so far (ie. the Alert and ActionSheet which we covered in the previous two videos), it is becoming increasingly more popular.

🤙 WELCOME BACK 🤙

Рекомендации по теме
Комментарии
Автор

Really like the consistency in your lessons. I don't think I've seen it anywhere else . . Keep pushing..

gregas
Автор

Thanks for the video <3.

My Learnings (MD: iOS 18) 📝
There are three context menu modifiers.
a. ContextMenu(() -> View) -> (You can attach this with any view)
(i) You can return buttons, pickers and toggles from context menu closure.

b. ContextMenu(menuItems: () -> View, preview: () -> View)
(i) Use this modifier when you want to show custom preview when context menu opens, the original view will hide.

c.
(i) Use with list type to open special context menu for a specific list item(s) selection.

Miscellaneous:
* You can create nested menus with `Menu`.
* You can combine multiple actions using `ControlGroup`. (cool one)
* You can change the shape of a specific view when context menu opens using .contentShape(kind:shape:) modifier.

the_avii_
Автор

This (if I'm being honest) was probably one of the most important and valuable videos.

DannyBoy
Автор

Thanks Nick! Hope you have a wonderful day 🤙

ConfidentlyRong-joyt
Автор

you're telling me its that easy to add a context menu and not many people use it? i love that freature

kaceyflieder
Автор

Thank you my dear friend! You are the best!

ShowMeLova
Автор

Hola! Thanks for videos, amazing work!) I have a question on your example: when the contextMenu is shown, cornerRadius doesn't look good. How we can clip corners to avoid right angles?

sergeylyadsky
Автор

Hi Nick! upon looking at Apple's documentation it appears contextMenu has been deprecated on everything except for macO, right?

seogun
Автор

Hi Nick, I add withAnimation(.spring( )) { backgroundColor = .yellow } inside the contextMenu, but it doesn't work. It seems that the reason is that I can't animate the View with the contextMenu() modifier within that modifier. Any solution?

Nick-gjgz
Автор

ContextMenu shows you a pop up with a long press. It’s the same behavior when you click on your apps on your iPhone with a 3D Touch. ContextMenu doesn’t require 3D Touch and it will work with a long press gesture.

Antonnel
Автор

Video is top! just don't forget to fix the cover😅 from content to context😅

saweekmusic
Автор

Noticed that on press corners are shadowed with rectangle pattern not shape with round corners

deltaKilo-M
Автор

Thank you so much for this great job, but please I have been trying to implement NavigationLink into the Button to link into a page but I' struggling with it.

toheeborelope
Автор

Hey do you know how to insert a NavigationLink in preview of the iOS 16 version of the context Menu ?

FabricioMTL
Автор

I agree, I would not use the ContextMenu without telling the users that there was one. Even in 2024. I use an iPhone and an iPad but I dont use the ContextMenu myself and that could make me a little curious as well.
As I do not want to tell users "Hey, there is a menu if you hold this and that item", I think I will not use it in my apps. Maybe as addition to other options.

Anyways it is good to know that is there and know how to use it.

youngdomsey
Автор

How to add a contexMenu on an icon of your app, for clarity, the icon you use to launch applications.

Денис-жфр
Автор

would've helped more if the example would save selected item to a list on a different page.😒

ClearTipTT
visit shbcf.ru