Global IM UIKit Dynamic Type

Dynamic Type 让字体随系统「文字大小」设置缩放。Global UIKit 的 typography 令牌支持这一点:组件默认使用 `UIFont.preferredFont(forTextStyle:)` 语义的字体,宿主可以整体替换,也可以按令牌覆盖。

字体令牌​

令牌类型建议
body—使用 preferredFont / UIFontMetrics 缩放
caption—使用 preferredFont / UIFontMetrics 缩放
title—使用 preferredFont / UIFontMetrics 缩放

实现方式​

// ios-imkit/uikit/customization/dynamic-type
var uiTheme = IMPChatUITheme.light
uiTheme.palette.brand = "#4F46E5"
print(uiTheme.palette.background)
theme.typography.body = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
theme.typography.caption = [UIFont preferredFontForTextStyle:UIFontTextStyleCaption1];
theme.typography.title = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(applyTheme)
                                             name:UIContentSizeCategoryDidChangeNotification
                                           object:nil];

验收点​

  • 系统文字调到最大后,会话列表与聊天消息不截断、不重叠(必要时改为多行 / 自适应高度)。
  • 气泡、输入区、时间分隔随字号缩放;固定尺寸图标保持不变。
  • 切换字号后无需重启 App,主题更新即在下次布局生效。
  • 与深色模式叠加时,颜色令牌仍保持对比度(≥ 3:1)。