CocoaPods trunk is moving to be read-only. Read more on the blog, there are 4 months to go.

AlertDisplayer 0.3.1

AlertDisplayer 0.3.1

Maintained by JC Macbook.



AlertDisplayer

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

This library runs by itself, it was created to replace the old and not stylish UIAlertView.

Installation

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

pod 'AlertDisplayer'

After installing AlertDisplayer you need to configurate a ViewController that has clear color in background, a view with top:0, bottom:0, leading:0, trailing:0 constraints relative to margins and a UIColor (light gray or black) with an alpha to create the dark (but still transparent) background. Then you add the view that inherits from AlertDisplayer and reference it in the VC and configure in the viewDidLoad like this:

    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.view.backgroundColor = .clear
        self.alertDisplayer.configureWith(self, 350, 250)

        // Do any additional setup after loading the view.
    }

And to configure it you also need to implement the Delegate:

extension ViewController: AlertDisplayerDelegate{
    
    func setUpButtons() {
        self.alertDisplayer.setUpButtons("Aceptar")
    }
    
    //Optional Method to set UIImage
    /*func setExitImage() -> UIImage? {
        return nil
    }*/
    
    func setFont(to label: UILabel) {
        label.font = UIFont.systemFont(ofSize: 15)
    }
    
    func setBoldFont(to label: UILabel) {
        label.font = UIFont.systemFont(ofSize: 20, weight: .bold)
    }
    
    func alertDisplayerDidLoad() {
        //Aditional Setup
        
        self.alertDisplayer.normalLabel.text = text
        self.alertDisplayer.boldLabel.text = titleText
        
        if(self.rightText != nil){
            self.alertDisplayer.setUpButtons(self.leftText, self.rightText)
        }else{
            self.alertDisplayer.setUpButtons(self.leftText)
        }
    }
    
    func didPressOk() {
        print("didPressOkDelegate")
        self.dismiss(animated: true, completion: nil)
    }
    
    func didPressCancel() {
        print("didPressCancelDelegate")
        self.dismiss(animated: true, completion: nil)
    }   
}

Author

JCTec, [email protected]

License

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