What is an asynchronous function?什么是异步函数?
Although Swift functions are synchronous by default, we can make them asynchronous by adding one keyword: async. Inside asynchronous functions, we can call other asy...
How to follow this guide 如何遵循本指南
This guide is called Swift Concurrency by Example because it focuses on providing as many examples as possible. My goal is to stay laser-focused on real-world problems and real-wor...
What is a synchronous function? 什么是同步函数?
By default, all Swift functions are synchronous, but what does that mean? A synchronous function is one that executes all its work in a simple, straight line on a single threa...
Transaction
当前状态处理更新的上下文。 transaction(value:_:) 使用.transaction 修饰符来更改或替换视图中使用的动画。考虑一个由按钮控制的三个相同视图,同时改变所有三个的情况: 第一个视图通过旋转...
phaseAnimator
一个容器,通过自动循环遍历你提供的一系列阶段来对其内容进行动画处理,每个阶段定义了动画中的一个离散步骤。 具有阶段动画的弹跳 例如,前面展示的表情符号弹跳动画具有两个阶段:向上移动和...
withAnimation
使用提供的动画重新计算视图主体,并返回结果。 struct ContentView: View { @State private var isActive = false var body: some View { VStack(alignment: isActive ? .trailing : .leading)...
Animation
当指定的值发生变化时,将给定的动画应用于此视图。 struct ContentView: View { @State private var scale = 0.5 var body: some View { VStack { Circle().scale(scale).animation(.easeIn, v...
SwiftData 调试
SwiftData 在调试时可以直接在输出窗口显示对应的 SQL 语句。 设置方法 点击如下的按钮,弹出 Scheme 窗口 在弹出的Scheme 窗口中,选择 Run菜单,然后选择 Argument 标签页,点击+号按钮。 然...
如何将 SwiftData 与 iCloud 同步
Xcode配置 如果要将应用程序的数据同步到 iCloud,请转到应用程序Target的 Signing & Capabilities 设置 添加 iCloud 功能 点击 + Capability 按钮,选择 iCloud 功能 选择 CloudKit 在 iCl...
如何动态更改查询的排序顺序或谓词
要实现动态排序,您需要将@Query属性移至 SwiftUI 层次结构中的视图中 - 您需要将其放入子视图中,在其中可以使用依赖项注入提供排序值。 这意味着创建一个新的 SwiftUI,它使用@Query来显示您...