SwiftUI 有哪些新功能向前相容?
Asked on 06/11/2025
1 search
在 WWDC 上,SwiftUI 引入了一些新功能,这些功能具有向前相容性,确保在现有应用中可以逐步采用这些新特性而不破坏现有功能。以下是一些关键的向前相容功能:
-
主线程隔离:SwiftUI 视图现在默认被标记为主线程隔离(main actor),这意味着如果你之前显式地将视图标记为主线程,现在可以移除这些标记而不影响行为。What's new in SwiftUI
-
改进的互操作性:SwiftUI 提供了更好的与 UIKit 和 AppKit 的互操作性。你可以在 SwiftUI 视图层次结构中使用 UIKit 的手势识别器,即使这些视图不是直接由 UIKit 支持的。What's new in SwiftUI
-
性能提升:SwiftUI 在列表和滚动性能上有显著提升,尤其是在 macOS 上,列表加载速度提高了 6 倍,更新速度提高了 16 倍。What's new in SwiftUI
这些改进使得 SwiftUI 更加灵活和高效,适合在现有应用中逐步引入新功能。

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

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.

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.