© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
W. WangBeginning iPhone Development with SwiftUIhttps://doi.org/10.1007/978-1-4842-7818-5_6

6. Responding to the User with Buttons and Segmented Controls

Wally Wang1  
(1)
San Diego, CA, USA
 

Every user interface needs to display information to the user whether that information may be text or images. However, another feature of a user interface is to accept commands from the user. The simplest way to accept commands through a user interface is through buttons.

Buttons represent a single command that can be as simple as a confirmation such as OK or Cancel. To create a Button, you need to define
  • The title that displays text on the button

  • Swift code that runs when ...

Get Beginning iPhone Development with SwiftUI: Exploring the iOS SDK 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.