SwiftUI For Dummies

by
Edition: 1st
Format: Paperback
Pub. Date: 2020-09-09
Publisher(s): For Dummies
  • Free Shipping Icon

    Free Shipping On Orders Over $59

    Free standard shipping on order over $59 to your home address. Marketplace purchases through third-party sellers are excluded from free shipping promotions.

List Price: $36.74

Buy New

Usually Ships in 2-3 Business Days
$34.99

Rent Book

Select for Price
There was a problem. Please try again later.

Digital

Rent Digital Options
Online:1825 Days access
Downloadable:Lifetime Access
$25.20
*To support the delivery of the digital material to you, a non-refundable digital delivery fee of $3.99 will be charged on each digital item.
$25.20*

Used Book

We're Sorry
Sold Out

How Marketplace Works:

  • This item is offered by an independent seller and not shipped from our warehouse
  • Item details like edition and cover design may differ from our description; see seller's comments before ordering.
  • Sellers much confirm and ship within two business days; otherwise, the order will be cancelled and refunded.
  • Marketplace purchases cannot be returned to eCampus.com. Contact the seller directly for inquiries; if no response within two days, contact customer service.
  • Additional shipping costs apply to Marketplace purchases. Review shipping costs at checkout.

Summary

Create the app of your dreams with SwiftUI

You have that sweet, sweet app idea but think you don’t yet have the coding skills to build it? Don’t fret about someone beating you to it: get going with your idea today using SwiftUI. SwiftUI makes it fast and simple for fledgling coders to take flight and develop world class iOS apps that soar above the rest—without having to learn all the tricks of coding right away.

Swift UI for Dummies has all you need to know, showing you how to quickly get a feel for coding rules, syntax, and tools, and to develop your basic knowledge in Swift 5.0 playgrounds. It also covers the frameworks and APIs that allow you to create smooth, intuitive interfaces with no trouble at all—just dive in and you’ll be posting your first application in record time. 

  • Combining projects into workspaces and creating playgrounds
  • Employing Xcode editing tools
  • Using constants and variables and work with optional types
  • Testing your code on iOS Simulator
The time is ripe—pick up this friendly guide and you’ll soon see your iOS app ideas join 350,000 others (and counting) built using Swift.

Author Biography

Wei-Meng Lee (Singapore) is founder of Developer Learning Solutions, a firm specializing in hands-on training for software developers. He teaches courses in mobile development, blockchain, machine learning, and AI. He is author of a number of books, including Beginning Swift Programming (Wiley).

Table of Contents

Introduction 1

About This Book 1

Foolish Assumptions 2

Icons Used in This Book 2

Beyond the Book 3

Where to Go from Here 3

Part 1: Getting Started with Swift and SwiftUI 5

Chapter 1: Introducing SwiftUI 7

Understanding What SwiftUI Is 7

Getting the Tools 11

Hello, SwiftUI 12

Automatically previewing your user interface using the canvas 14

Working with Live Preview 18

Generating different previews 19

The Gory Details 21

Info plist 22

AppDelegate swift 22

SceneDelegate swift 23

Chapter 2: Basics of the Swift Programming Language 25

Basic Swift Syntax 26

Constants 26

Variables 27

Strings 27

Comments 27

Basic Data Types 28

Integers 28

Floating-point numbers 29

Booleans 29

Tuples 30

Arrays 30

Retrieving elements from an array 31

Inserting elements into an array 31

Modifying elements in an array 31

Appending elements to an array 31

Removing elements from an array 32

Dictionaries 32

Retrieving elements from a dictionary 32

Modifying an item in a dictionary 33

Removing an item from a dictionary 33

Optional Types 33

Working with implicitly unwrapped optionals 35

Using optional binding 36

Unwrapping optionals using “?” 36

Using the nil coalescing operator 37

Functions 38

Understanding input parameters 38

Returning a value 39

Flow Control 39

If-Else statement 40

Ternary conditional operator 40

Switch statement 40

Looping 41

For-In loop 42

While loop 42

Repeat-While loop 42

Control transfer statements 42

Range operators 43

Structures 43

Memberwise initializers 44

Structures as value types 45

Classes 47

Defining a class 47

Understanding properties 47

Using methods in classes 49

Trying out the self property 50

Closures 51

Understanding closures 51

Using functions as closures 52

Assigning closures to variables 52

Writing closures inline 53

Understanding type inference 53

Using shorthand argument names 54

Working with the operator function 54

Using trailing closures 55

Protocols 55

Defining and using a protocol 56

Conforming to a protocol 56

Using the Codable protocol 57

Using the some keyword 59

Part 2: Understanding the Basics of SwiftUI 61

Chapter 3: Getting Started with the Basics of SwiftUI 63

Taking a Look at SwiftUI Views 63

Conforming to the View protocol 64

Using modifiers 66

Stacking modifiers 66

Using the Inspector 67

Displaying an Image 70

Using modifiers on the Image view 72

Resizing images 73

Displaying a Button 75

Customizing the button 76

Adding actions 77

Stacking the Views 78

VStack 79

HStack 80

Putting on the Finishing Touches 85

Chapter 4: Handling User Inputs and Custom Views 87

Looking at Input Views 87

TextField 88

SecureField 92

Toggle 93

Slider 94

Stepper 98

Picker 100

Composing Custom Views 103

Composing the custom view 104

Using the custom view 111

Chapter 5: Displaying Lists of Items 113

Using the List View to Display Items 113

Customizing the rows 114

Adding rows programmatically 116

Alternative way to generate rows in a List view 119

Displaying the List within a NavigationView 120

Making the items tappable 121

Adding rows 123

Using the Identifiable protocol 125

Deleting rows 126

Editing rows 128

Moving rows 130

Displaying Sections 133

Displaying sections from a dictionary 134

Changing the style of the List view 136

Previewing in Light and Dark Modes 138

During runtime 138

During design time 139

Chapter 6: Creating Navigation and Tabbed Applications 143

Creating Navigation Apps 144

Working with the two key views in navigation-style apps 145

Navigating to a page 148

Navigating programmatically 149

Creating a news reader application 151

Creating Tabbed Applications 167

Using the TabView 168

Selecting TabViews programmatically 169

Chapter 7: Formatting Your User Interface 173

Laying Out Views Using Stacks 173

VStack 174

HStack 186

ZStack 190

Using Container Views 195

Form and Section 198

Group 200

Divider 203

Part 3: Exploring with SwiftUI in More Detail 205

Chapter 8: Understanding State Management in SwiftUI 207

Using a Property Wrapper 207

Maintaining State Using State Variables 209

Binding State Variables 213

Managing State from External Objects 218

Using the ObservableObject protocol and @Published 219

Using the @ObservedObject 221

Sharing Objects 223

Accessing Built-in Environment Variables 228

Defining your own environment keys 230

Using your own environment keys 231

Chapter 9: Using Legacy UIKit Views and View Controllers in SwiftUI 235

Using UIKit in SwiftUI 236

Understanding the UIKit View Controller life cycle 237

Understanding the SwiftUI view life cycle 239

Using the UIViewRepresentable Protocol for UIKit Views 247

ActivityIndicator 248

WebView 251

Using the UIViewControllerRepresentable Protocol for UIKit View Controllers 253

Creating the ImagePickerViewController 254

Handling events using coordinators 256

Defining the methods in the Coordinator class 258

Using the updated ImagePickerViewController 260

Part 4: Performing Animations and Drawings 263

Chapter 10: Drawings and Special Effects 265

Drawing Using the Five Built-in Shapes 266

Rectangles 266

Rounded rectangles 270

Circles 273

Capsules 274

Ellipses 275

Clipping with the Basic Shapes 277

Drawing Custom Shapes 281

Drawing lines 283

Filling the shape 284

Drawing a border 286

Drawing an arc 287

Combining fill and stroke 289

Using Special Effects in SwiftUI 292

Blend modes 292

Blurs 297

Saturation 298

Chapter 11: Performing Animations in SwiftUI 299

Understanding How to Animate 299

Specifying the type of animation 303

Repeating the animation 303

Stopping the animation 304

Performing Your Own Animation 307

Rotating in 2D 307

Rotating in 3D 309

Creating a Custom Progress Indicator 314

Indeterminate progress indicator 314

Determinate progress indicator 318

Chapter 12: Creating a Complete Project 323

Understanding What the App Does 323

Building the Project 325

Creating the layouts 325

Defining the news sources and observable objects 328

Fetching the data 330

Displaying the news headlines 331

Displaying the images 334

Displaying the news 336

Creating the share sheet 338

Creating the preferences view 339

Persisting the user’s preferences 344

Deploying the App 346

Part 5: The Part of Tens 351

Chapter 13: Ten SwiftUI Tips and Tricks 353

Resuming Live Preview 353

Implementing Localization 354

Combining Text Views 358

Creating Custom Modifiers 360

Displaying Multiple Alerts 362

Enabling Debug Preview 363

Previewing Using Different Devices 364

Dark Mode Only Works On NavigationView 368

Extracting Subviews 370

Displaying a Context Menu 373

Chapter 14: Ten Great SwiftUI Resources 375

Apple 375

SwiftUI by Example 376

100 Days of SwiftUI 376

Gosh Darn SwiftUI 376

SwiftUI Hub 376

Awesome SwiftUI 377

raywenderlich com 377

Swift Talk 377

About SwiftUI 377

Stack Overflow 378

Appendix: Code Snippets for Common Swiftui Views 379

Index 387

An electronic version of this book is available through VitalSource.

This book is viewable on PC, Mac, iPhone, iPad, iPod Touch, and most smartphones.

By purchasing, you will be able to view this book online, as well as download it, for the chosen number of days.

Digital License

You are licensing a digital product for a set duration. Durations are set forth in the product description, with "Lifetime" typically meaning five (5) years of online access and permanent download to a supported device. All licenses are non-transferable.

More details can be found here.

A downloadable version of this book is available through the eCampus Reader or compatible Adobe readers.

Applications are available on iOS, Android, PC, Mac, and Windows Mobile platforms.

Please view the compatibility matrix prior to purchase.