YAlert 0.6.0

YAlert 0.6.0

测试测试
语言语言 SwiftSwift
许可证 MIT
发布上次发布2017年10月
SwiftSwift版本3.0
SPM支持SPM

Leo Feng维护。



YAlert 0.6.0

  • Leo Feng

YAlert




简介

YAlert是一个自定义警报视图控制器,具有指定横幅图片、标题、消息、主要按钮操作和次要按钮操作的功能。

用法

在您的视图控制器中,您可以使用以下代码初始化并呈现一个AlertViewController实例:

let alertVC = AlertViewController(bannerImageName: "banner",
                                            title: "Alert #1",
                                          message: "This is a message",
                                          primaryButtonTitle: "Ok",
                                          secondaryButtonTitle: "Cancel")
alertVC.tag = 1000
alertVC.delegate = self
alertVC.present()

有两个属性用于处理AlertViewController呈现时用户事件。

delegate允许您的视图控制器接收和处理主要按钮、次要按钮和背景点击事件。

tag允许您在处理点击事件时区分AlertViewController实例。您可以根据AlertViewController的tag编号有不同的事件处理逻辑。

extension ViewController: AlertViewControllerDelegate {
    func didTapPrimaryButton(_ sender: AlertViewController) {
        switch sender.tag {
        case 1000:
            print("1000")
        case 2000:
            print("2000")
        default:
            print("no tag")
        }

        print("primary button tapped")
    }

    func didTapSecondaryButton(_ sender: AlertViewController) {
        print("secondary button tapped")
    }

    func didTapBackground(_ sender: AlertViewController) {
        print("background tapped")
    }
}

安装

YAlert通过CocoaPods可用。要安装,
只需将以下行添加到您的Podfile中。

pod "YAlert"

作者

Leo Feng, [email protected]

许可证

YAlert可在MIT许可证下使用。有关更多信息,请参阅LICENSE文件。