EAAlert
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
Requirements
Installation
EAAlert is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'EAAlert'
How To Use
Firstly, import EAAlert to your project
import EAAlert
Define EAAlert variable in global scope
var alert: EAAlert!
Set the instance in viewDidLoad
alert = EAAlert()
alert = EAAlert(message: "Test message")
To show alert
alert.show()
You can set the message with using setMessage function when you need
alert.setMessage("Updated message")
Set message type as success, error or none. There will be icons if success or error selected.
alert.messageType = .success // .error or .none
Set distribution of positive and negative buttons
alert.actionButtonsDistribution = .fillEqually
Set positive and negative button visibility
alert.isPositiveButtonHidden = false // default true
alert.isNegativeButtonHidden = false // default true
Click events
onAlertCloseTapped, onNegativeButtonTapped, and onPositiveButtonTapped
alert.onAlertCloseTapped = {
print("onAlertCloseTapped")
}
alert.onNegativeButtonTapped = {
print("onNegativeButtonTapped")
}
alert.onPositiveButtonTapped = {
print("onPositiveButtonTapped")
}
Customize
You can change close, success and error icons.
alert.closeButtonImage = UIImage(named: "close")
alert.successButtonImage = UIImage(named: "tick")
alert.errorButtonImage = UIImage(named: "cross")
Update alert background color and set blur type
alert.blurEffectStyle = .dark
alert.alertBackgroundColor = .black
Set message label font and color
alert.messageLabelFont = UIFont.systemFont(ofSize: 20)
alert.messageLabelColor = .lightText
Set positive and negative buttons' text, font, and color
alert.positiveButtonTextFont = UIFont.boldSystemFont(ofSize: 23)
alert.positiveButtonTextColor = .white
alert.positiveButtonText = "Ok"
alert.negativeButtonTextFont = UIFont.boldSystemFont(ofSize: 23)
alert.negativeButtonTextColor = .white
alert.negativeButtonText = "Cancel"
Author
aydin-emre, www.emr.ee
License
EAAlert is available under the MIT license. See the LICENSE file for more info.