PopupView
介绍
CustomPopup 允许您以UIAlert样式模态地展示任何动态调整大小以适应其内容的视图控制器。
示例
要运行示例项目,请克隆存储库,并首先在 Example 目录中运行 pod install
。
安装
PopupView 通过 CocoaPods 可用。要安装它,只需将以下行添加到 Podfile 中
pod 'CustomPopup'
用法
您要展示弹出窗口的控制器应遵守 PopUpPresentationController 协议
public protocol PopUpPresentationController {
var gesture: UIGestureRecognizer? { get set }
var popUp: PopUpController? { get set }
func dismissPopUp()
}
展示弹出窗口
let popUpController = YourCustomPopUpViewController()
popUp = PopUpController(popUpView: popUpController)
guard let popUp = popUp else { return }
popUp.presentPopUp(on: self)
当在模态视图外部点击时添加一个手势以销毁弹出窗口可能很有用
gesture = UITapGestureRecognizer(target: self, action: #selector(dismissPopUp))
gesture?.delegate = self //implement gestureRecognizer:shouldReceiveTouch:
guard let gesture = gesture else { return }
self.view.addGestureRecognizer(gesture)
作者
acsmith25,[email protected]
许可证
PopupView在MIT许可证下可用。更多信息请参阅LICENSE文件。