Swift 与 SwiftUI 新的变化
Asked on 2025-06-15
1 search
在 WWDC 上,Apple 介绍了 Swift 和 SwiftUI 的一些新变化。
Swift 的变化
- Swift 6 语言模式:Swift 6 引入了编译时数据竞争安全性。这意味着在编译时可以检测到数据竞争问题,从而提高代码的安全性和稳定性。
- Swift 的并发模型:继续改进了并发模型,包括异步/等待、actor 和结构化并发。
- C++ 互操作性:Swift 现在支持与 C++ 的互操作性,使得在 Swift 中使用 C++ 代码更加容易。
SwiftUI 的变化
-
新功能和改进:
- 图形能力:SwiftUI 现在支持颜色混合和自定义着色器的预编译,以避免因延迟编译导致的帧丢失。
- 滚动视图控制:提供了更细粒度的滚动视图控制,包括检测视图可见性变化和程序化滚动到特定位置。
- Web 内容支持:引入了新的 WebKit API,允许在 SwiftUI 中嵌入和控制 Web 内容。
- 富文本编辑:SwiftUI 的文本编辑器现在支持富文本编辑,通过将文本编辑器的绑定从字符串更改为属性字符串来实现。
- 性能改进:列表和滚动性能显著提升,尤其是在处理大数据集时。
-
跨平台一致性:SwiftUI 继续在所有 Apple 平台上提供一致的用户体验,支持新的设计系统和界面元素。
如果你想了解更多关于 SwiftUI 的具体变化,可以查看 What’s new in SwiftUI (00:00:07) 和 Platforms State of the Union (00:35:23) 这两个会话。

What’s new in SwiftUI
Learn how you can use SwiftUI to build great apps for any Apple platform. Explore a fresh new look and feel for tabs and documents on iPadOS. Improve your window management with new windowing APIs, and gain more control over immersive spaces and volumes in your visionOS apps. We’ll also take you through other exciting refinements that help you make expressive charts, customize and layout text, and so much more.

Platforms State of the Union
Discover the newest advancements on Apple platforms.

What’s new in SwiftUI
Learn what’s new in SwiftUI to build great apps for any Apple platform. We’ll explore how to give your app a brand new look and feel with Liquid Glass. Discover how to boost performance with framework enhancements and new instruments, and integrate advanced capabilities like web content and rich text editing. We’ll also show you how SwiftUI is expanding to more places, including laying out views in three dimensions.