SwiftUI For Dummies - Wei-Meng Lee

SwiftUI For Dummies

(Autor)

Buch | Softcover
416 Seiten
2020
For Dummies (Verlag)
978-1-119-65268-7 (ISBN)
32,10 inkl. MwSt
The simplest way to create world-class apps

Have a unique app idea but worried you don't quite have the coding skills to build it? Good news: You can stop fretting about someone beating you to market with the same idea and start work right now using SwiftUI. SwiftUI is a gateway app development framework that has become one of the best ways for fledgling developers to get iOS apps off the ground without having to become a coding expert overnight.

SwiftUI For Dummies makes that process even faster, providing a friendly introduction to the SwiftUI and Swift programming language and helping you feel right at home creating and building with playgrounds. The book also covers the frameworks and APIs that make it so easy to create smooth, intuitive interfaces—just dive right in and have fun!



Combine projects into workspaces
Employ Xcode editing tools
Use constants and variables
Test your code on iOS Simulator

Time is of the essence, and with SwiftUI For Dummies, it's also on your side. Get going with this friendly guide today, and you'll be celebrating the successful launch of your app way before you thought possible!

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).

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

Erscheinungsdatum
Sprache englisch
Maße 185 x 229 mm
Gewicht 544 g
Themenwelt Informatik Programmiersprachen / -werkzeuge Mac / Cocoa Programmierung
Informatik Software Entwicklung Mobile- / App-Entwicklung
ISBN-10 1-119-65268-5 / 1119652685
ISBN-13 978-1-119-65268-7 / 9781119652687
Zustand Neuware
Haben Sie eine Frage zum Produkt?
Mehr entdecken
aus dem Bereich