You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在iPadOS 18中禁用UITabBarController新视图样式

iPadOS 18 标签栏新API与样式禁用问题

iPadOS 18引入了用于创建标签栏的新API。

Create a UITabBarController and assign an array of UITab objects to its tabs property.

请问如何在iPadOS 18中禁用该新样式,保持标签栏位于底部?

iPadOS 18新标签栏样式


解决方案

要在iPadOS 18中维持标签栏在底部的传统样式,可通过以下两种方式实现:

1. 改用传统API配置标签栏

如果你原本使用了新的tabs属性创建标签栏,直接换回传统的viewControllers数组来配置UITabBarController即可:

let tabBarController = UITabBarController()
// 用viewControllers数组替代新的tabs属性
tabBarController.viewControllers = [vc1, vc2, vc3]

这种方式会自动沿用底部标签栏的旧样式,不会触发iPadOS 18的侧边标签栏新样式。

2. 强制设置标签栏位置(适配已用新API的场景)

如果已经使用了tabs属性,可通过设置tabBarPosition属性为.bottom来强制固定底部位置:

let tabBarController = UITabBarController()
tabBarController.tabs = [UITab(viewController: vc1), UITab(viewController: vc2)]
// 强制指定标签栏在底部
tabBarController.tabBarPosition = .bottom

补充说明

  • tabBarPosition是iPadOS 18新增属性,需确保项目部署目标包含iPadOS 18及以上版本。
  • 若使用Interface Builder,可在UITabBarController的属性检查器中找到标签栏位置选项,选择「Bottom」即可完成设置。

内容的提问来源于stack exchange,提问作者Ric Santos

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 07:32:35