PopupController是一个用于显示临时弹出视图的控制器。
在Appetize.io上尝试PopupController
在使用之前,
所有添加到PopupController的ViewController都必须遵守PopupContentViewController协议。
class AnyPopupViewController: UIViewController, PopupContentViewController {
// Do something...
private var popupSize: CGSize // define the size for showing popup view size.
// PopupContentViewController Protocol
func sizeForPopup(popupController: PopupController, size: CGSize, showingKeyboard: Bool) -> CGSize {
return popupSize
}
}
然后,显示弹出窗口
PopupController
.create(self)
.show(AnyPopupViewController())
进行一些自定义。
PopupController
.create(self)
.customize(
[
.Animation(.FadeIn),
.Layout(.Top),
.BackgroundStyle(.BlackFilter(alpha: 0.7))
]
)
.show(AnyPopupViewController())
使用处理程序
PopupController
.create(self)
.customize(
[
.Scrollable(false),
.DismissWhenTaps(true)
]
)
.didShowHandler { popup in
// Do something
}
.didCloseHandler { _ in
// Do something
}
.show(AnyPopupViewController())
如果您使用PopupController实例,可以这样做
let popup = PopupController
.create(self)
.customize(
[
.Animation(.SlideUp)
]
)
.didShowHandler { popup in
// Do something
}
.didCloseHandler { _ in
// Do something
}
popup.show() // show popup
popup.dismiss() // dismiss popup
public enum PopupCustomOption {
case Layout(PopupController.PopupLayout)
case Animation(PopupController.PopupAnimation)
case BackgroundStyle(PopupController.PopupBackgroundStyle)
case Scrollable(Bool)
case DismissWhenTaps(Bool)
case MovesAlongWithKeyboard(Bool)
}
PopupController遵循MIT许可证。有关更多信息,请参阅LINCENSE文件。