ema

EMAlertController

EMAlertController is a beautiful alternative to the stock iOS UIAlertController

Showing:

Popularity

Downloads/wk

0

GitHub Stars

181

Maintenance

Last Commit

1yr ago

Contributors

5

Package

Dependencies

0

License

MIT

Categories

Readme

Icon

Language license CocoaPods GitHub stars CocoaPods

EMAlertController is a beautiful alternative to the stock iOS UIAlertController. This library is fully customizable with an implementation like the native UIAlertController.

Icon

Table of Contents

Features

  • Alert Image (Optional)
  • Title
  • Scrollable Message (Optional)
  • Text Fields
  • Closure when a button is pressed
  • Fully Customizable
  • CocoaPods

Requirements

  • iOS 9.0+
  • Xcode 9+

Installation

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

$ gem install cocoapods

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

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

target '<Your Target Name>' do
pod 'EMAlertController'
end

Then, run the following command:

$ pod install

Usage

let alert = EMAlertController(title: "EMAlertView Title", message: "This is a simple message for the EMAlertView")

let cancel = EMAlertAction(title: "CANCEL", style: .cancel)
let confirm = EMAlertAction(title: "CONFIRM", style: .normal) {
// Perform Action
}

alert.addAction(cancel)
alert.addAction(confirm)

Customization

Alert View


Icon

let icon = UIImage(named: "imageName")

alert.iconImage = icon

Title

alert.titleText = "Sample Title"

Title Color

alert.titleColor = UIColor.red
// Default color = UIColor.black

Message

alert.messageText = "Sample message"

Message Color

alert.messageColor = UIColor.red
// Default color = UIColor.black

Message Data Detector Types

alert.dataDetectorTypes = .all

Messages Make Message Selectable

alert.isMessageSelectable = true
// This must be set to `true` in order to highlight the detected data types

Corner Radius

alert.cornerRadius = 10
// Default corner radius = 5

Background Color

alert.backgroundColor = UIColor.white
// Default color = UIColor(red: 250/255, green: 250/255, blue: 250/255, alpha: 1.0)

Background View Color

alert.backgroundViewColor = UIColor.red
// Default color = UIColor.darkGray

Background View Alpha

alert.backgroundViewAlpha = 1.0
// Default alpha = 0.2

Alert Actions


Title

action.title = "Sample Title"

Title Color

action.titleColor = UIColor.red
// Normal style action default color = UIColor(red: 53/255, green: 53/255, blue: 53/255, alpha: 1.0)
// Cancel style action default color = UIColor(red: 230/255, green: 57/255, blue: 70/255, alpha: 1.0)

Title Font

action.titleFont = UIFont.systemFont(ofSize: 14)
// Default font = UIFont.boldSystemFont(ofSize: 16)

Background Color

action.actionBackgroundColor = UIColor.red
// Default color = UIColor.clear

Button Spacing (Only when two buttons are displayed in horizontal)

alert.buttonSpacing = 0
// Default spacing = 15

TextFields


Adding a Text Field

 alert.addTextField { (textField) in
   textField?.placeholder = "Username"
 }

Getting Text from Text Field

guard let username = alert.textFields.first?.text else { return }

TODO

  • Carthage Support
  • Actions Scroll Support

License


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

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100