PMAlertController - 一个伟大的和可自定义的警报,可以替代UIAlert控制器

图标

语言
GitHub 许可证
豆荚版本
迦太基兼容
下载

PMAlertController 是一个小型库,可让您替换 Apple 的不可定制 ,带有一个漂亮且完全可自定义的警报,您可以在 iOS 应用程序中使用。 享受!UIAlertController

图标

Features


  • [x] Header View
  • [x] Header Image (Optional)
  • [x] Title
  • [x] Description message
  • [x] Customizations: fonts, colors, dimensions & more
  • [x] 1, 2 buttons (horizontally) or 3+ buttons (vertically)
  • [x] Closure when a button is pressed
  • [x] Text Fields support
  • [x] Similar implementation to UIAlertController
  • [x] Cocoapods
  • [x] Carthage
  • [x] Animation with UIKit Dynamics
  • [x] Objective-C compatibility
  • [x] Swift 4, Swift 4.2 & Swift 5 support
  • [ ] Swift Package Manager

Requirements


  • iOS 9.0+
  • Xcode 10+

CocoaPods


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

$ gem install cocoapods
Bash

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'
Ruby

Then, run the following command:

$ pod install
Bash

Carthage


Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage
Bash

To integrate PMAlertController into your Xcode project using Carthage, specify it in your :Cartfile

github "pmusolino/PMAlertController"
Ogdl

Run to build the framework and drag the built into your Xcode project.carthage updatePMAlertController.framework

Manually


  1. Download and drop folder in your project./Library
  2. Congratulations!

Usage


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

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 location, push notifications and more.

Show a simple alert with two buttons and one textfield

//This code works with Swift 5

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")
        }))

alertVC.addTextField { (textField) in
            textField?.placeholder = "Location..."
        }

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

Swift

Swift compatibility

Third Party Bindings

React Native

You may now use this library with React Native via the module here

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.

Follow me on:

? Linkedin

? Twitter

? Instagram

??‍? Facebook

MIT License


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

GitHub

https://github.com/pmusolino/PMAlertController