-
让你的 App 为 iPhone Duo 做好准备
了解如何针对 iPhone Duo 的折叠显示屏更新并优化你的 App。了解如何选择加入全屏体验、采用灵活布局的最佳实践,并在 Xcode 的 Device Hub 中模拟各种折叠姿态。了解如何使用尺寸级别而不是界面方向、处理不对称的安全区域,以及测试 Split View 多任务处理,以确保你的 App 在用户的各种使用方式下都能大放异彩。
章节
- 0:00 - Introduction
- 0:30 - Build with the latest SDK
- 1:17 - Get started in Xcode
- 1:33 - Adopt flexible layouts
- 2:46 - Use size classes
- 3:57 - Avoid screen assumptions
- 5:01 - Adopt standard navigation
- 6:06 - Respect safe areas
- 8:08 - Use reserved regions
- 9:12 - Next steps
资源
相关视频
Tech Talks
WWDC26
-
搜索此视频…
-
-
2:59 - Read size classes
// SwiftUI @Environment(\.horizontalSizeClass) private var horizontalSizeClass @Environment(\.verticalSizeClass) private var verticalSizeClass // UIKit traitCollection.horizontalSizeClass traitCollection.verticalSizeClass -
4:16 - Access the screen from the window scene
// Avoid referencing the main screen on a two-display device. // Access the screen dynamically from the window scene instead. let screen = window?.windowScene?.screen -
4:30 - Match the screen corners with Concentricity
// SwiftUI ConcentricRectangle() .fill(Color.green) .padding(8.0) .ignoresSafeArea() // UIKit // UICornerConfiguration -
5:44 - Show a sidebar on the inner display
// SwiftUI TabView { … } .defaultTabBarPlacement(.sidebar) // UIKit tabBarController.sidebar.preferredPlacement = .sidebar -
6:52 - Align foreground content to the safe area
// UIKit foreground.frame = view.bounds.inset(by: view.safeAreaInsets) -
7:07 - Let background content extend past the safe area
// SwiftUI .ignoresSafeArea() // UIKit backgroundView.frame = view.bounds -
7:30 - Handle asymmetric safe area insets
// Avoid assuming insets on opposite sides are equal let width = view.bounds.width - view.safeAreaInsets.left * 2 // Handle each side independently let width = view.bounds.inset(by: view.safeAreaInsets).width -
9:25 - Replace main screen references
func updateThumbnail(from image: UIImage) { // Before let screenScale = UIScreen.main.scale // After let screenScale = traitCollection.displayScale // ... }
-
-
- 0:00 - Introduction
David Jackson from the UI Frameworks team outlines how to bring your app to iPhone Duo: getting started in Xcode, general resizing guidance, and layout guidance specific to iPhone Duo.
- 0:30 - Build with the latest SDK
Your app runs on iPhone Duo even without recompiling, but screen usage improves with each SDK. The iOS 27 SDK extends your app left of the status bar on the inner display; the iOS 27.1 SDK reaches the screen edge and lays standard navigation and toolbar buttons out vertically.
- 1:17 - Get started in Xcode
Download Xcode 27.1 and run your app in the iPhone Duo simulator using DeviceHub. On-screen control buttons let you open, close, rotate, and fold the device to check your layout in every pose.
- 1:33 - Adopt flexible layouts
iPhone Duo extends the long-standing need for adaptive layout — new screen shapes, camera locations, and iPhone mirroring on the Mac. Avoid assumptions about display size or capability based on user interface idiom, and design across a continuum of sizes.
- 2:46 - Use size classes
Size classes express the experience your app should provide for the available space — the environment in SwiftUI, trait collection in UIKit. The outer display behaves like other iPhone models, while the inner display is regular in both dimensions, leaving room for sidebars. The inner display doesn't honor supported interface orientations, so use size classes rather than orientation for layout decisions.
- 3:57 - Avoid screen assumptions
Don't reference the main screen on a two-display device — it's ambiguous and will be deprecated. Prefer the environment, trait collection, or the scene's bounds, and access screens dynamically from the window scene. Use the iOS 26 Concentricity APIs, ConcentricRectangle and UICornerConfiguration, to fit the screen's corners.
- 5:01 - Adopt standard navigation
NavigationSplitView, UISplitViewController, TabView, and UITabBarController are fully adaptive across every pose — columns collapse when closed and tile or overlay when open. On the inner display you can opt into a sidebar placement for richer navigation. Sheets, popovers, context menus, and alerts adapt as well.
- 6:06 - Respect safe areas
Standard bars lay out outside the safe area and automatically avoid the status bar and camera. Keep interactive foreground content inside the safe area, and let background artwork extend past it with ignoresSafeArea or the view's bounds. Safe areas and layout margins are often asymmetric on iPhone Duo, so handle each side independently and test in Split View.
- 8:08 - Use reserved regions
New in iOS 27.1, ReservedRegion in SwiftUI and UIViewReservedRegion in UIKit let custom UI claim as much screen space as possible without colliding with system UI — useful for custom bars and edge-to-edge designs.
- 9:12 - Next steps
The app modernization skill introduced in "Modernize your UIKit app" is now called App Resizability in Xcode 27.1, with support for SwiftUI and iPhone Duo. Download Xcode 27.1, simulate with DeviceHub, follow the adaptive layout practices, and try the skill.