SwiftUI 入门指南

Sep 29, 2021 • 预计阅读时间 2 分钟

Introducing SwiftUI

SwiftUI is a modern way to declare user interfaces for any Apple platform. Create beautiful, dynamic apps faster than ever before.

SwiftUI Essentials

Learn how to use SwiftUI to compose rich views out of simple ones, set up data flow, and build the navigation while watching it unfold in Xcode’s preview.

Creating and Combining Views

Create a new Xcode project that uses SwiftUI. Explore the canvas, previews, and the SwiftUI template code.

https://developer.apple.com/tutorials/swiftui/creating-and-combining-views

Building Lists and Navigation

With the basic landmark detail view set up, you need to provide a way for users to see the full list of landmarks, and to view the details about each location.

https://developer.apple.com/tutorials/swiftui/building-lists-and-navigation

Handling User Input

In the Landmarks app, a user can flag their favorite places, and filter the list to show just their favorites. To create this feature, you’ll start by adding a switch to the list so users can focus on just their favorites, and then you’ll add a star-shaped button that a user taps to flag a landmark as a favorite.

https://developer.apple.com/tutorials/swiftui/handling-user-input

Drawing and Animation

Discover how to draw shapes and paths to create a badge that you’ll animate, while also creating seamless transitions between views.

Drawing Paths and Shapes

Users receive a badge whenever they visit a landmark in their list. Of course, for a user to receive a badge, you’ll need to create one. This tutorial takes you through the process of creating a badge by combining paths and shapes, which you then overlay with another shape that represents the location.

https://developer.apple.com/tutorials/swiftui/drawing-paths-and-shapes

Animating Views and Transitions

When using SwiftUI, you can individually animate changes to views, or to a view’s state, no matter where the effects are. SwiftUI handles all the complexity of these combined, overlapping, and interruptible animations for you.

https://developer.apple.com/tutorials/swiftui/animating-views-and-transitions

App Design and Layout

Explore the structure and layout of more complex interfaces built with SwiftUI.

Composing Complex Interfaces

The category view for Landmarks shows a vertically scrolling list of horizontally scrolling landmarks. As you build this view and connect it to your existing views, you’ll explore how composed views can adapt to different device sizes and orientations.

https://developer.apple.com/tutorials/swiftui/composing-complex-interfaces

Working with UI Controls

In the Landmarks app, users can create a profile to express their personality. To give users the ability to change their profile, you’ll add an edit mode and design the preferences screen.

https://developer.apple.com/tutorials/swiftui/working-with-ui-controls

Framework Integration

Use SwiftUI views together with the views and view controllers from platform-specific UI frameworks.

Interfacing with UIKit

SwiftUI works seamlessly with the existing UI frameworks on all Apple platforms. For example, you can place UIKit views and view controllers inside SwiftUI views, and vice versa.

https://developer.apple.com/tutorials/swiftui/interfacing-with-uikit

Creating a watchOS App

This tutorial gives you a chance to apply much of what you’ve already learned about SwiftUI, and — with little effort — migrate the Landmarks app to watchOS.

https://developer.apple.com/tutorials/swiftui/creating-a-watchos-app

Creating a macOS App

After creating a version of the Landmarks app for watchOS, it’s time to set your sights on something bigger: bringing Landmarks to the Mac. You’ll build upon everything you’ve learned so far, to round out the experience of building a SwiftUI app for iOS, watchOS, and macOS.

https://developer.apple.com/tutorials/swiftui/creating-a-macos-app

SwiftSwiftUI
版权声明:如果转发请带上本文链接和注明来源。

lvv.me

iOS/macOS Developer

Swift 5 静态编译

使用命令行工具测试 APNs