PTools 5.62.2 — TabBar Content Size 修正
中文
修复内容
tabItemContentInsets 从 5.62.2 开始直接控制 PTTabBarItemView 中媒体或自定义
content.view 的实际尺寸,不再只改变外围容器的可用边界。
PTAppBaseConfig.share.tabItemContentInsets = UIEdgeInsets(
top: 3,
left: 3,
bottom: 3,
right: 3
)
如果基础内容尺寸是 32 × 32,结果为 26 × 26。计算规则为:
width = baseWidth - left - right
height = baseHeight - top - bottom
正值会缩小内容,有限负值会扩展内容;异常的 NaN / Infinity 会被安全归零,扩展尺寸最多为基础尺寸的两倍。
内容尺寸由 PTTabBarLayoutEngine.contentSize 统一计算,供 Item、Badge 和 Mini 模式复用。
tabSelectedMetailInsets 仍然只改变选中背景,tabItemContentOffset 仍然只平移 Icon + Title 整体。
标题由字体和 Dynamic Type 独立决定,不会因为内容 Insets 被缩放。
优先级与兼容性
项目级 PTTabBarItemConfig.contentInsets 优先于外观全局配置,未提供时使用当前
PTTabBarAppearance 快照;.zero 保持 5.62.1 的默认视觉尺寸。已有 TabBar 的外观快照行为不变,
修改 PTAppBaseConfig.share 不会隐式刷新已经创建的实例。
自定义 PTTabBarItemContent.view 不应再添加 required 的根宽高约束,根尺寸由 TabBar Item 统一管理。
如果业务需要固定尺寸,应在外层配置 Insets,避免与 TabBar 的尺寸约束冲突。
迁移验证
Example 的 TabBar Item Insets Demo 提供 Legacy、Selection、正/负 Content Insets、Vertical、Horizontal、
Offset、Combined、Per-item、Badge、Mini 和 Lottie 十二种场景,并显示每个 content.view 的实际尺寸。
建议验证:UIImage、SF Symbol、Lottie、远程图片、自定义 View、无标题/长标题、Dynamic Type、Badge 三种样式、 Normal ↔ Mini 往返,以及 iPhone/iPad 横竖屏。完整真机视觉结果需要集成方在目标宿主中确认。
English
Fix
Starting with 5.62.2, tabItemContentInsets changes the actual size of the media or custom
content.view inside PTTabBarItemView. It no longer acts only as padding on an outer container.
Positive insets shrink the content, finite negative insets expand it, and non-finite values are normalized to zero.
Expansion is capped at twice the base size. PTTabBarLayoutEngine.contentSize is the single calculation used by
the item, badges and minimized mode.
tabSelectedMetailInsets still affects only the selected surface. tabItemContentOffset still translates the
complete icon-and-title group without resizing it. The title keeps its own font and Dynamic Type sizing.
Per-item PTTabBarItemConfig.contentInsets overrides the appearance snapshot. .zero preserves the default
5.62.1 visual size, and modifying PTAppBaseConfig.share does not mutate an existing appearance snapshot.
Migration
Do not add required width or height constraints to the root view of a custom PTTabBarItemContent. Let the TabBar
Item own that size. Use the updated TabBar Item Insets Demo to inspect actual bounds for raster, Lottie, badge and
mini configurations. Device and host visual validation remains an integration responsibility.
Español
Corrección
Desde 5.62.2, tabItemContentInsets cambia el tamaño real de content.view para contenido multimedia o personalizado
dentro de PTTabBarItemView; ya no funciona solamente como padding de un contenedor exterior.
Los valores positivos reducen el contenido y los negativos finitos lo amplían. NaN e Infinity se convierten en cero y
la expansión se limita al doble del tamaño base. PTTabBarLayoutEngine.contentSize es el cálculo único utilizado por
el elemento, los badges y el modo minimizado.
tabSelectedMetailInsets continúa afectando solo a la superficie seleccionada. tabItemContentOffset traslada el
grupo completo de icono y título sin cambiar su tamaño. El título conserva su propia fuente y Dynamic Type.
El contentInsets de PTTabBarItemConfig tiene prioridad sobre el snapshot de apariencia. .zero conserva el tamaño
visual predeterminado de 5.62.1 y modificar PTAppBaseConfig.share no cambia instancias ya creadas.
Migración
No añadas restricciones required de ancho o alto a la vista raíz de un PTTabBarItemContent personalizado. El tamaño
debe ser administrado por el TabBar Item. El Demo TabBar Item Insets permite revisar los bounds reales para raster,
Lottie, badges y modo minimizado. La validación visual en dispositivo y en el host real corresponde a la integración.