Overloads
2 ways to call compose().presentationCompactAdaptation(). Each is one SwiftUI overload, picked by the arguments you pass.
compose().presentationCompactAdaptation(
adaptation: SwiftUI.PresentationAdaptation
)nonisolated func presentationCompactAdaptation(
_ adaptation: PresentationAdaptation
) -> some ViewParameters
adaptation*SwiftUI.PresentationAdaptationThe adaptation to use in either a horizontally or vertically compact size class.
Discussion
Some presentations adapt their appearance depending on the context. For
example, a sheet presentation over a vertically-compact view uses a
full-screen-cover appearance by default. Use this modifier to indicate
a custom adaptation preference. For example, the following code
uses a presentation adaptation value of PresentationAdaptation.none
to request that the system not adapt the sheet in compact size classes:
struct ContentView: View {
@State private var showSettings = false
var body: some View {
Button("View Settings") {
showSettings = true
}
.sheet(isPresented: $showSettings) {
SettingsView()
.presentationDetents([.medium, .large])
.presentationCompactAdaptation(.none)
}
}
}If you want to specify different adaptations for each dimension,
use the View.presentationCompactAdaptation(horizontal:vertical:)
method instead.
See also
More in Presentation.
- alertPresents an alert when a given condition is true, using a localized string resource for the title.
- confirmationDialogPresents a confirmation dialog when a given condition is true, using a localized string resource for the title.
- contextMenuAdds an item-based context menu to a view.
- dialogIconConfigures the icon used by dialogs within this view.
- dialogSuppressionToggleEnables user suppression of dialogs and alerts presented within self, with a custom suppression message on macOS. Unused on other platforms.
- dismissalConfirmationDialogPresents a confirmation dialog upon an attempt to dismiss the window for this view.
- documentBrowserContextMenuAdds to a DocumentLaunchView actions that accept a list of selected files as their parameter.
- fileDialogBrowserOptionsOn macOS, configures the fileExporter, fileImporter, or fileMover to provide a refined URL search experience: include or exclude hidden files, allow searching by tag, etc.
- fileDialogConfirmationLabelOn macOS, configures the fileExporter, fileImporter, or fileMover with a custom confirmation button label.
- fileDialogCustomizationIDOn macOS, configures the fileExporter, fileImporter, or fileMover to persist and restore the file dialog configuration.
- fileDialogDefaultDirectoryConfigures the fileExporter, fileImporter, or fileMover to open with the specified default directory.
- fileDialogImportsUnresolvedAliasesOn macOS, configures the fileExporter, fileImporter, or fileMover behavior when a user chooses an alias.