SwiftUI For Dummies

22,99 €*

Lieferzeit Sofort lieferbar

SwiftUI For Dummies, Wiley
Von Wei-Meng Lee, im heise Shop in digitaler Fassung erhältlich
Format
(Hinweis: DRM-geschützt)
Anzahl:
Artikel-Beschreibung
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
Artikel-Details
Anbieter:
Wiley
Autor:
Wei-Meng Lee
Artikelnummer:
9781119652724
Veröffentlicht:
12.08.2020
Seitenanzahl:
416