Global IM UIKit 主题定制

主题由 ChatUITheme 统一约束:palette(颜色)、typography(字体)、layout(布局)三组令牌,提供浅色 / 深色预设。组件只读令牌,不硬编码颜色,因此换肤不需要改组件源码。

令牌​

palette​

令牌类型说明
background—页面背景
surface—卡片 / 输入区背景
textPrimary—主文本
textSecondary—次要文本(时间、状态)
brand—品牌色(发送按钮、选中态)
danger—失败 / 危险操作

typography​

令牌类型说明
body—正文(支持 Dynamic Type)
caption—辅助文本
title—标题

layout​

令牌类型说明
bubbleRadius—气泡圆角
avatarSize—头像尺寸
spacing—通用间距

行为​

  • 浅色/深色两套预设
  • 动态字体(Dynamic Type)
  • 宿主可整体覆盖或按组件覆盖
  • 运行中切换主题即时生效

示例​

// ios-imkit/uikit/customization/theme
var uiTheme = IMPChatUITheme.light
uiTheme.palette.brand = "#4F46E5"
print(uiTheme.palette.background)
IMPOSGlobalChatUITheme *theme = [IMPOSGlobalChatUITheme globalLight];
theme.palette.brand = [UIColor systemIndigoColor];
theme.layout.bubbleRadius = 16;

IMPOSGlobalChatUITheme *dark = [IMPOSGlobalChatUITheme globalDark];
listViewController.theme = theme;   // 运行中切换即时生效

相关:Dynamic Type、ChatUITheme。