PTDAlertViewController 1.0.1

PTDAlertViewController 1.0.1

pontake-dev 维护。



  • 作者
  • pontake-dev

PTDAlertViewController

Carthage compatible Version License Platform

PTDAlertViewController 是围绕 UIalertController 的一种包装,通过简单代码显示警报。
PTDAlertViewController 是通过简单代码实现警报对话框的 UIalertController 包装器。

描述

  • 不带按钮的消息对话框显示。
    无按钮的消息对话框显示。

    在经过一段时间后,会显示一个消息对话框,该对话框将自动关闭。您也可以指定关闭的秒数。
    此外,用户点击消息对话框的外部区域时,可以从立即擦除对话框。
    经过一定时间后自动关闭的消息对话框显示。可以指定关闭的秒数。通过点击消息对话框外部,用户可以立即擦除对话框。
    sample image001

  • 显示一个按钮的消息对话框显示。
    只显示一个按钮的消息对话框显示。

    您可以通过关闭来检测是否点击了对话框按钮。
    可以通过关闭来获取对话框按钮点击的事件。
    sample image001

  • 显示两个按钮的消息对话框显示。
    显示两个按钮的消息对话框显示。

    您可以通过关闭来检测是否点击了对话框按钮。
    可以通过关闭来获取对话框按钮点击的事件。
    sample image001

示例用法

// MARK: Message dialogue display with no button.

PTDAlertViewController.showDialog(title: "title", message: "message")
//When specifying all arguments
PTDAlertViewController.showDialog(title: nil, message: "message", animated: true, showTime: 1.0)

// MARK: Message dialogue display that displays one button.

PTDAlertViewController.showYesOnlyAlert(title: "title", message: "message") {
    print("Alert Yes button tapped.")
}
//When specifying all arguments
PTDAlertViewController.showYesOnlyAlert(title: nil, message: "message", yesButtonMessage: "agree", animated: true) {
    print("Alert Yes button tapped.")
}

// MARK: Message dialogue display to display two buttons.
PTDAlertViewController.showYesNoAlert(title: "title", message: "message") { (isYesTapped) in
    if isYesTapped {
        print("Alert Yes button tapped.")
    } else {
        print("Alert No button tapped.")
    }
}
//When specifying all arguments
PTDAlertViewController.showYesNoAlert(title: nil, message: "message", yesButtonMessage: "done", noButtonMessage: "cancel", animated: true) { (isYesTapped) in
    if isYesTapped {
        print("Alert Yes button tapped.")
    } else {
        print("Alert No button tapped.")
    }
}

安装

CocoaPods

添加到 Podfile

pod 'PTDAlertViewController'

Carthage

添加到 Cartfile

github "pontake-dev/PTDAlertViewController"

许可协议

MIT