wwdc25 中 webview 的改变
Asked on 2025-10-31
1 search
在 WWDC 2025 中,Apple 对 WebView 进行了显著的更新,特别是在 SwiftUI 中的集成。以下是一些关键的变化:
-
WebView API: WebView 是一个新的 SwiftUI 视图,用于在应用中显示网页内容。它由 WebKit 提供支持,允许应用通过初始化 WebView 来显示 URL,并可以自定义和与页面交互。
-
WebPage API: 这是一个新的可观察模型类型,专为 Swift 设计。WebPage 使得与网页的丰富交互成为可能,允许程序化地在页面上导航并访问页面属性。
-
自定义用户体验: 新的 WebKit API 支持自定义用户代理、调用 JavaScript、处理自定义 URL 方案等功能。
-
滚动和交互: WebView 支持强大的滚动自定义功能,例如仅在内容大于视图时才水平弹跳。此外,在 Vision OS 上引入了“Look to scroll”功能,可以通过简单的视图修饰符进行配置。
-
查找功能: WebView 现在支持“Find in page”功能,用户可以轻松搜索页面内容。
要了解更多关于这些新功能的详细信息,可以查看 Meet WebKit for SwiftUI (00:01:54) 和 What’s new in SwiftUI (00:20:04) 的相关章节。

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.

Meet WebKit for SwiftUI
Discover how you can use WebKit to effortlessly integrate web content into your SwiftUI apps. Learn how to load and display web content, communicate with webpages, and more.

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