iOS Dev Nugget 210 PMAlertController


Need to run a code review on your codebase? Hire me

UIAlertController was introduced in iOS 8 providing a block-based API among other changes. But it is still not very customizable. If you want to show e.g a large image or otherwise more customizable content, PMAlertController is one good solution. It has a similar API to UIAlertController and is available via CocoaPods and Carthage.

Here's sample code from the README (Swift 3):

let alertVC = PMAlertController(title: "A Title", description: "My Description", image: UIImage(named: "img.png"), style: .alert)

alertVC.addAction(PMAlertAction(title: "Cancel", style: .cancel, action: { () -> Void in
            print("Capture action Cancel")

alertVC.addAction(PMAlertAction(title: "OK", style: .default, action: { () in
            print("Capture action OK")

self.present(alertVC, animated: true, completion: nil)

PS: For the last 2 days, I was at iOS Conf SG along with a great lineup of speakers including @natashatherobot, @merowing_, @_ryannystrom and @inamiy. If you are interested in my talk, here's a link to the deck. The videos for the all the talks should be up soon. I'll post links soon.

Your feedback is valuable: Do you want more nuggets like this?   Yes   or   No



Like this and want such iOS dev nuggets to be emailed to you, weekly?

Sign Me Up! or follow @iosdevnuggets on Twitter


View archives of past issues