YAlert 0.6.0

YAlert 0.6.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Oct 2017
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Leo Feng.



YAlert 0.6.0

  • By
  • Leo Feng

YAlert




Introduction

YAlert is a customized alert view controller featuring the ability to specify a banner image, title, message, primary button action and secondary button action.

Usage

In your view controller, you can initialize and present an AlertViewController instance using the following code:

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()

There are two properties responsible for handling user events when AlertViewController is present.

delegate allows your view controller to receive and handle primary button, secondary button, and background tap events.

tag allows you to differentiate AlertViewController instances when handling tap events. You may have different event handling logic based on the AlertViewController’s tag number.

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")
    }
}

Installation

YAlert is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "YAlert"

Author

Leo Feng, [email protected]

License

YAlert is available under the MIT license. See the LICENSE file for more info.