轻量应用内消息通知:主题铺底、滑动关闭、同侧多条堆叠。无第三方依赖。
CocoaPods:
pod 'ZHHInAppMessage'Swift Package Manager:
.package(url: "https://github.com/yue5yueliang/ZHHInAppMessage.git", from: "1.0.0")import ZHHInAppMessage
ZHHInAppMessage.showMessage(
title: "温馨提示",
message: "请确认当前设置后再继续。",
icon: .image(ZHHInAppMessageTheme.info.icon),
theme: .info,
buttonTitle: "关闭",
buttonHandler: { /* 业务逻辑 */ }
)- 消息卡片:四槽自由组合(图标 / 标题 / 正文 / 按钮)
- 自定义内容布局(
show(customView:)/showCustomView),外壳仍由库统一管理 - 主题铺底(info / success / warning / error),自适应 Dark Mode
- 顶 / 底展示,同侧叠卡并存(最多错开 2 层,更深完全重叠)
- 滑动关闭、遮罩模式(穿透 / 点击关闭)
- 去重、按 id 隐藏
behavior(时长、位置、交互、回调)与style(字体、间距、图标尺寸等)分组配置
var config = ZHHInAppMessageConfig()
config.behavior.duration = .seconds(3)
config.behavior.position = .top
config.behavior.dismissOnAction = true
config.behavior.dismissOnTap = false
config.behavior.onShow = { print("shown") }
config.behavior.onHide = { print("hidden") }
// 默认四槽外观:可改字体 / 图标 / 间距;也可用 .compact
config.style = .regular
config.style.titleFont = .boldSystemFont(ofSize: 16)
config.style.iconSize = CGSize(width: 28, height: 28)
ZHHInAppMessage.showMessage(
title: "已保存",
theme: .success,
buttonTitle: "好的",
config: config
)自定义布局:
var config = ZHHInAppMessageConfig()
config.behavior.position = .top
config.style.cornerRadius = 14
ZHHInAppMessage.showCustomView(myView, id: "promo", config: config)连续 show 多条时全部保留并叠卡;视觉上最多错开两层,更后面的完全重叠,各条按时长自行消失。最前一张滑出退场,peek 层收起露出边,更深层淡出。
- 通知列表与持久化
- 便捷 Banner API(基于现有外壳)
MIT
