-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

SwiftUI Cookbook
By :

A popover is a view that can be displayed on screen to provide more information about a particular item. They include an arrow pointing to the location where they originate from. You can tap on any other screen area to dismiss the popover. Popovers are typically used on larger screens such as iPads.
In this recipe, we will create and display a popover on an iPad.
Create a new SwiftUI project named DisplayingPopovers
.
Following the pattern we've used so far in this chapter, we shall first create a @State
variable whose value triggers the displaying or hiding of a popover. Then we add a .popover()
modifier that displays the popover when the @State
variable is true
. The steps are as follows:
body
variable in the ContentView.swift
file, add a state
variable that will be used to trigger the display of the popover:@State private var showPopover = false }
body
variable, replace the Text...