You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

161 lines
5.4 KiB

  1. <p align="center">
  2. <img src="https://raw.githubusercontent.com/pmusolino/PMAlertController/master/logo_pmalertcontroller.png" alt="Icon"/>
  3. </p>
  4. [![Language](https://img.shields.io/badge/Swift-3%20%26%204-orange.svg)]()
  5. [![GitHub license](https://img.shields.io/cocoapods/l/PMAlertController.svg)](https://github.com/pmusolino/PMAlertController/blob/master/LICENSE)
  6. [![Pod version](https://img.shields.io/cocoapods/v/PMAlertController.svg?style=flat)](https://cocoapods.org/pods/PMAlertController)
  7. [![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-yellow.svg)](https://github.com/Carthage/Carthage)
  8. [![Downloads](https://img.shields.io/cocoapods/dt/PMAlertController.svg)](https://cocoapods.org/pods/PMAlertController)
  9. 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!
  10. <p align="center">
  11. <img src="https://raw.githubusercontent.com/pmusolino/PMAlertController/master/preview_pmalertacontroller.png" width=800 alt="Icon"/>
  12. </p>
  13. ## Features
  14. ----------------
  15. - [x] Header View
  16. - [x] Header Image (Optional)
  17. - [x] Title
  18. - [x] Description message
  19. - [x] Customizations: fonts, colors, dimensions & more
  20. - [x] 1, 2 buttons (horizontally) or 3+ buttons (vertically)
  21. - [x] Closure when a button is pressed
  22. - [x] Text Fields support
  23. - [x] Similar implementation to UIAlertController
  24. - [x] Cocoapods
  25. - [x] Carthage
  26. - [x] Animation with UIKit Dynamics
  27. - [x] Objective-C compatibility
  28. - [x] Swift 2.3, Swift 3 and Swift 4 support
  29. - [ ] Swift Package Manager
  30. ## Requirements
  31. ----------------
  32. - iOS 9.0+
  33. - Xcode 9+
  34. ## CocoaPods
  35. ----------------
  36. [CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command:
  37. ```bash
  38. $ gem install cocoapods
  39. ```
  40. To integrate PMAlertController into your Xcode project using CocoaPods, specify it in your `Podfile`:
  41. ```ruby
  42. source 'https://github.com/CocoaPods/Specs.git'
  43. platform :ios, '9.0'
  44. use_frameworks!
  45. pod 'PMAlertController'
  46. ```
  47. Then, run the following command:
  48. ```bash
  49. $ pod install
  50. ```
  51. ## Carthage
  52. ----------------
  53. [Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
  54. You can install Carthage with [Homebrew](http://brew.sh/) using the following command:
  55. ```bash
  56. $ brew update
  57. $ brew install carthage
  58. ```
  59. To integrate PMAlertController into your Xcode project using Carthage, specify it in your `Cartfile`:
  60. ```ogdl
  61. github "pmusolino/PMAlertController"
  62. ```
  63. Run `carthage update` to build the framework and drag the built `PMAlertController.framework` into your Xcode project.
  64. ## Manually
  65. ----------------
  66. 1. Download and drop ```/Library``` folder in your project.
  67. 2. Congratulations!
  68. ## Usage
  69. ----------------
  70. The usage is very similar to `UIAlertController`.
  71. `PMAlertController` has two styles: Alert & Walkthrough.
  72. **Alert Style:** with this style, the alert has the width of 270 points, like Apple's `UIAlertController`.
  73. **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 location, push notifications and more.
  74. #### Show a simple alert with two buttons and one textfield
  75. ```swift
  76. //This code works with Swift 4
  77. let alertVC = PMAlertController(title: "A Title", description: "My Description", image: UIImage(named: "img.png"), style: .alert)
  78. alertVC.addAction(PMAlertAction(title: "Cancel", style: .cancel, action: { () -> Void in
  79. print("Capture action Cancel")
  80. }))
  81. alertVC.addAction(PMAlertAction(title: "OK", style: .default, action: { () in
  82. print("Capture action OK")
  83. }))
  84. alertVC.addTextField { (textField) in
  85. textField?.placeholder = "Location..."
  86. }
  87. self.present(alertVC, animated: true, completion: nil)
  88. ```
  89. ## Swift compatibility
  90. - If you use **Swift 4.0 or higher**, you can use the [latest release](https://github.com/pmusolino/PMAlertController/releases).
  91. - If you use **Swift 3**, you can use the [release 2.1.3](https://github.com/pmusolino/PMAlertController/releases/tag/2.1.3).
  92. - If you use **Swift 2.3**, you can use the [release 1.1.0](https://github.com/pmusolino/PMAlertController/releases/tag/1.1.0)
  93. - If you use **Swift 2.2**, you can use the [release 1.0.5](https://github.com/pmusolino/PMAlertController/releases/tag/1.0.5)
  94. ## Third Party Bindings
  95. ### React Native
  96. You may now use this library with [React Native](https://github.com/facebook/react-native) via the module [here](https://github.com/prscX/react-native-styled-dialogs)
  97. ## Contributing
  98. - If you **need help** or you'd like to **ask a general question**, open an issue.
  99. - If you **found a bug**, open an issue.
  100. - If you **have a feature request**, open an issue.
  101. - If you **want to contribute**, submit a pull request.
  102. ## Acknowledgements
  103. Made with ❤️ by [Paolo Musolino](https://github.com/pmusolino).
  104. The design is inspired by the [Musement App](https://itunes.apple.com/app/musement-tours-attractions/id828471190). The flag icon on the demo app is by [Freepik](http://freepik.com).
  105. ## MIT License
  106. ----------------
  107. PMAlertController is available under the MIT license. See the LICENSE file for more info.