PopupController 0.2.0

PopupController 0.2.0

测试测试
语言语言 SwiftSwift
许可证 MIT
发布最近发布2016年9月
SPM支持SPM

Daisuke Sato维护。



PopupController

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文件。