EMAlertController is a beautiful alternative to the stock iOS UIAlertController. This library is fully customizable with an implementation like the native UIAlertController.
- Features
- Requirements
- Installation
- Usage
- Customization
- Icon
- Title
- Title Color
- Message
- Message Color
- Corner Radius
- Background Color
- Background View Color
- Text Fields
- Todo
- License
- Alert Image (Optional)
- Title
- Scrollable Message (Optional)
- Text Fields
- Closure when a button is pressed
- Fully Customizable
- CocoaPods
- iOS 9.0+
- Xcode 9+
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
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)
let icon = UIImage(named: "imageName")
alert.iconImage = icon
alert.titleText = "Sample Title"
alert.titleColor = UIColor.red
// Default color = UIColor.black
alert.messageText = "Sample message"
alert.messageColor = UIColor.red
// Default color = UIColor.black
alert.dataDetectorTypes = .all
alert.isMessageSelectable = true
// This must be set to `true` in order to highlight the detected data types
alert.cornerRadius = 10
// Default corner radius = 5
alert.backgroundColor = UIColor.white
// Default color = UIColor(red: 250/255, green: 250/255, blue: 250/255, alpha: 1.0)
alert.backgroundViewColor = UIColor.red
// Default color = UIColor.darkGray
alert.backgroundViewAlpha = 1.0
// Default alpha = 0.2
action.title = "Sample Title"
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)
action.titleFont = UIFont.systemFont(ofSize: 14)
// Default font = UIFont.boldSystemFont(ofSize: 16)
action.actionBackgroundColor = UIColor.red
// Default color = UIColor.clear
alert.buttonSpacing = 0
// Default spacing = 15
alert.addTextField { (textField) in
textField?.placeholder = "Username"
}
guard let username = alert.textFields.first?.text else { return }
- Carthage Support
- Actions Scroll Support
EMAlertController is available under the MIT license. See the LICENSE file for more info.