6

Presenting Views Modally

When we want to draw the user’s attention to an important task and offer focused interaction, we present a view modally. Modality is a design technique that presents content in a separate view that prevents interaction with the parent view and requires a specific action to be dismissed. For example, suppose the users of your app are about to perform an irreversible action such as permanently deleting a file. In that case, they should probably be shown an alert asking for confirmation of whether they want to proceed with the action. Then, depending on the user’s response, the file would be deleted or left alone.

Since SwiftUI is a declarative programming language, presenting content modally mainly involves adding modifiers ...

Get SwiftUI Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.