轻量级 iOS 弹窗框架,基于 UIKit,无第三方依赖。
- 弹窗展示:支持居中、顶部、底部、左右等位置,可配置遮罩(纯色 / 模糊 / 无)
- 动画:内置淡入淡出、缩放、滑动,支持自定义
EPopupAnimatable - 键盘避让:遵循
EPopupKeyboardResponsive即可自动跟随键盘 - 弹窗链:
EPopupChainDispatcher支持单次或顺序弹出多个弹窗
| 项目 | 版本 |
|---|---|
| iOS | 14.0+ |
| Swift | 5.9+,兼容Swift6 |
- File → Add Package Dependencies...
- 输入仓库地址,选择版本后添加
- 在 Target 的 Frameworks, Libraries, and Embedded Content 中勾选
EPopup
dependencies: [
.package(url: "https://github.com/smelloftime/EPopup.git", from: "1.0.0")
],
targets: [
.target(
name: "YourApp",
dependencies: ["EPopup"]
)
]import EPopup
// 1. 弹窗视图遵循 EPopupPresentable
class MyPopupView: UIView, EPopupPresentable {
func preferredPopupSize(in container: UIView) -> CGSize {
CGSize(width: 300, height: 200)
}
}
// 2. 展示
var config = EPopupConfiguration()
config.placement = .center
config.animationType = .scale()
EPopupPresenter.show(MyPopupView(), in: view, config: config)
// 3. 关闭
EPopupPresenter.dismiss(popupView)更多示例见 Example。