How to programmatically present a menu when single-tap a table view row, like in the iOS 16 Calendar app?

Viewed 16

In the iOS 16 Calendar app, there is a new drop-down menu style for options like "repeat", when tapping any place of the row, a menu appeared. And there is a chevron up and chevron down icon at the right side of the table view cell.

How to do this in iOS 16? The context menu is triggered by long press, but this new style is by single-tap.

iOS 16 Calendar app create new event page with repeat option

1 Answers

It seems this is SwiftUI only. I can't find changes in iOS 16 UIKit to achieve this. In SwiftUI:

import SwiftUI

struct SettingsView: View {
    @State private var selectedFlavor: Flavor = .chocolate

    var body: some View {
        List {
            Picker("Flavor", selection: $selectedFlavor) {
                Text("Chocolate").tag(Flavor.chocolate)
                Text("Vanilla").tag(Flavor.vanilla)
                Text("Strawberry").tag(Flavor.strawberry)
            }
        }
    }
}

struct SettingsView_Previews: PreviewProvider {
    static var previews: some View {
        SettingsView()
    }
}

enum Flavor: String, CaseIterable, Identifiable {
    case chocolate, vanilla, strawberry
    var id: Self { self }
}
Related