Instance Method インスタンスメソッド

familyActivityPicker(isPresented:selection:)

Presents an activity picker view as a sheet.

Declaration 宣言

func familyActivityPicker(isPresented: Binding<Bool>, selection: Binding<FamilyActivitySelection>) -> some View

Parameters パラメータ

isPresented

A binding that indicates whether the app presents the picker view.

selection

A binding that manages the user-selected categories, apps, and web domains.

Discussion 議論

Use this view modifier to present a FamilyControls/FamilyActivityPicker.


struct ExampleView: View {
    @State var selection = FamilyActivitySelection()
    @State var isPresented = false


   var body: some View {
       Button("Present FamilyActivityPicker") { isPresented = true }
       .familyActivityPicker(isPresented: $isPresented,
                             selection: $selection)
       .onChange(of: selection) { newSelection in
           let applications = selection.applications
           let categories = selection.categories
           let webDomains = selection.webDomains
       }
   }
}