I'm trying to implement a menu on Apple Watch using SwiftUI but I can't find a way to do it. Even on the interface.storyboard
, I can't drag/drop the menu.
Did you manage to make it work with SwiftUI? If yes, how?
I searched online but nothing so far.
Unfortunately, Apple has removed this touch technology with the introduction of watchOS 7. Here we will know all about the Force Touch on Apple Watch and why the company has killed this incredibly helpful touch technology. If you are curious to know more about it, read on to unravel the truth.
Easily access more options with just a touchThe Apple Watch's Force Touch feature is the wearable device's version of 3D Touch on the iPhone. These features let you unlock new options and shortcuts by pressing on your device's screen.
Yes, this is possible. It's important to remember that unlike on iOS, a view can have only one single context menu, individual elements within the view can not have their own context menu.
Anyway, to implement a context menu (force touch menu) on Apple Watch with SwiftUI, add the .contextMenu()
modifier to top-most view in your body
Example:
var body: some View {
Group {
Text("Hello Daymo")
}
.contextMenu(menuItems: {
Button(action: {
print("Refresh")
}, label: {
VStack{
Image(systemName: "arrow.clockwise")
.font(.title)
Text("Refresh view")
}
})
})
}
Edit the button (or add buttons) as you see fit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With