BDCustomAlertController 0.1.1

BDCustomAlertController 0.1.1

Maintained by Benny Davidovitz.



  • By
  • Benny Davidovitz

BDCustomAlertController

CI Status Version License Platform

What does it do?

UIAlertAction

  • Display an UIImage within UIAlertAction using actionWithTitle:image:style:handler:

  • Display Image and Text using your prefered layout (leader or trailing) by invoking actionWithCustomContent:handler:

UIAlertController

  • Computed Tint Color

  • Date Picker as Cotent View Controller

  • More Content Options will be added as you request

Example

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

Display an UIAlertAction with text and image
    func displayAlertActionWithImage(){
        
        let alert = UIAlertController(title: "yo!", message: "a message", preferredStyle: .alert)
        let action = UIAlertAction(title: "Your Text", image: UIImage(named: "your_image_name"), style: .default) { (_) in
            //some code to handle the action
        }
        alert.addAction(action)
        
        self.present(alert, animated: true, completion: nil)
        
    }
Display an UIAlertController with UIDatePicker
    func displayAlertWithDatePicker(){
        let alert = UIAlertController(title: "yo!", message: "select a date messsage", preferredStyle: .alert)
        alert.insertDatePicker { (datePicker) in
            //config date picker as you like here
        }
        
        alert.addAction(UIAlertAction(title: "Done", style: .default, handler: { (_) in
            guard let datePicker = alert.datePicker() else{
                return
            }
            
            print("selected date is \(datePicker.date)")
        }))
        
        self.present(alert, animated: true, completion: nil)
        
    }

Installation

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

pod 'BDCustomAlertController'

Author

Benny Davidovitz

License

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