EzPopup
什么是 EzPopup
如果您在尝试在 iOS 设备上以弹出形式展示视图或视图控制器时感到困难,这个库就是为您准备的。使用 EzPopup,您可以轻松地显示弹出窗口,如下所示
示例
要运行示例项目,请克隆仓库,然后首先从 Example 目录中运行 pod install
兼容性
- iOS 13 及以上。
- Swift 5.1 及以上(对于更早的 Swift 版本,请使用更早的
ImageScrollView
版本)。
如果您在尝试在 iOS 设备上以弹出形式展示视图或视图控制器时感到困难,这个库就是为您准备的。使用 EzPopup,您可以轻松地显示弹出窗口,如下所示
要运行示例项目,请克隆仓库,然后首先从 Example 目录中运行 pod install
ImageScrollView
版本)。或者
文件 > Swift 包 > 添加包依赖 添加 https://github.com/huynguyencong/EzPopup.git 使用“更新到下一个主版本”并选择“1.0.0”
EzPopup 可通过 CocoaPods 获得。要安装它,只需将以下行添加到您的 Podfile 中
pod 'EzPopup'
使用弹出视图控制器非常简单
首先,使用您要显示的视图或视图控制器初始化一个 PopupViewController
// init YourViewController
let contentViewController = ...
// Init popup view controller with content is your content view controller.
// You can let your content view determine pop up size by using its intrinsic size by setting popupWidth and popupHeight nil.
// You can also set position by the position param. If you want show a pop up below a view, use .offsetFromView for position param.
let popupVC = PopupViewController(contentController: contentViewController, popupWidth: 100, popupHeight: 200)
// show it by call present(_ , animated:) method from a current UIViewController
present(popupVC, animated: true)
可选:如果您想的话,可以自定义一些 PopupViewController
的属性。例如
popupVC.backgroundAlpha = 0.3
popupVC.backgroundColor = .black
popupVC.canTapOutsideToDismiss = true
popupVC.cornerRadius = 10
popupVC.shadowEnabled = true
huynguyencong, [email protected]
EzPopup 以下 MIT 许可协议提供。有关更多信息,请参阅 LICENSE 文件