SwiftUI TabView旋转时内边距不生效问题求助
iOS 17.2 + Xcode 15.2 下 TabView 页面样式旋转异常问题
使用带有.tabViewStyle(.page(indexDisplayMode: .never))修饰符的自定义轮播TabView时,整体运行正常,但设备旋转后底部会出现异常内边距:

通过调试视图排查发现,视图顶部原点被错误偏移约10px:

以下是可复现问题的代码片段,运行环境为Xcode 15.2和iOS 17.2:
import SwiftUI @main struct TabViewDemoIssueApp: App { var body: some Scene { WindowGroup { ContentView() .ignoresSafeArea(.all, edges: .all) } } } struct ContentView: View { var body: some View { TabView { Rectangle().foregroundColor(.red) .ignoresSafeArea(.all, edges: .all) Rectangle().foregroundColor(.yellow) .ignoresSafeArea(.all, edges: .all) } .ignoresSafeArea(.all, edges: .all) .background(.green) .frame(maxWidth: .infinity, maxHeight: .infinity) .tabViewStyle(.page(indexDisplayMode: .never)) } } #Preview { ContentView() }
更新说明:已向苹果提交Bug报告,编号FB13526097
内容的提问来源于stack exchange,提问作者valvoline
相关产品推荐
相关产品推荐

