github

Codeido / PMAlertController

  • пятница, 20 мая 2016 г. в 03:15:17
https://github.com/Codeido/PMAlertController

Swift
PMAlertController is a great and customizable substitute to UIAlertController



Icon

Language GitHub license

PMAlertController is a small library that allows you to substitute Apple's uncustomizable UIAlertController, with a beautiful and totally customizable alert that you can use in your iOS app. Enjoy!

Icon

Features


  • Header Image (Optional)
  • Title
  • Description message
  • Customizations: fonts, colors, dimensions & more
  • 1, 2 buttons (horizontally) or 3+ buttons (vertically)
  • Closure when a button is pressed
  • Similar implementation to UIAlertController
  • Cocoapods
  • Carthage
  • Animation with UIKit Dynamics

Requirements


  • iOS 9.0+
  • Xcode 7.3+

CocoaPods


CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate PMAlertController into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

pod 'PMAlertController'

Then, run the following command:

$ pod install

Usage


The usage is very similar to UIAlertController. PMAlertController has two styles: Alert & Walkthrough.

Alert Style: with this style, the alert has the width of 270 points, like Apple's UIAlertController.

Walkthrough Style: with walkthrough, the alert has the width of the screen minus 18 points from the left and the right bounds. This mode is intended to be used before authorization requests like the ones for position, push notifications and more.

Show a simple alert with two button

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.presentViewController(alertVC, animated: true, completion: nil)

Contributing

  • If you need help or you'd like to ask a general question, open an issue.
  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Acknowledgements

Made with ❤️ by Paolo Musolino. The design is inspired by the Musement App. The flag icon on the demo app is by Freepik.

MIT License


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