TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Oct 2016 |
SPMSupports SPM | ✗ |
Maintained by Mario Iannotta.
A simple fully customizable alert controller
pod 'MIAlertController', '~> 1.0'
to your Podfile or copy the “MIAlertController” folder to your project.MIAlertController(
title: "Your alert title",
message: "Your alert description",
buttons: [
MIAlertController.Button(title: "Button one", action: {
print("button one tapped")
}),
MIAlertController.Button(title: "Button two", action: {
print("button two apped
})
]
).presentOn(self)
// Alert UI and behavior
var googlishAlertControllerConfig = MIAlertController.Config()
googlishAlertControllerConfig.firstButtonRatio = 0.8
googlishAlertControllerConfig.alertViewCornerRadius = 1
googlishAlertControllerConfig.messageLabelTextColor = UIColor(white: 0.45, alpha: 1)
googlishAlertControllerConfig.messageVerticalSpaceFromTitle = 25
googlishAlertControllerConfig.messageLabelFont = UIFont.systemFontOfSize(17)
googlishAlertControllerConfig.alertMarginSize = CGSize(width: 10, height: 10)
googlishAlertControllerConfig.alertViewMaxSize = CGSize(width: UIScreen.mainScreen().bounds.size.width - 80, height: 340)
googlishAlertControllerConfig.titleLabelTextAlignment = NSTextAlignment.Left
googlishAlertControllerConfig.messageLabelTextAlignment = NSTextAlignment.Left
// Buttons UI
var googlishAlertControllerLeftButtonConfig = MIAlertController.Button.Config()
googlishAlertControllerLeftButtonConfig.textColor = UIColor(red: 19/255.0, green: 152/255.0, blue: 138/255.0, alpha: 1)
googlishAlertControllerLeftButtonConfig.textAlignment = .Right
googlishAlertControllerLeftButtonConfig.font = UIFont.boldSystemFontOfSize(15)
var googlishAlertControllerRightButtonConfig = MIAlertController.Button.Config()
googlishAlertControllerRightButtonConfig.textColor = UIColor(red: 19/255.0, green: 152/255.0, blue: 138/255.0, alpha: 1)
googlishAlertControllerRightButtonConfig.font = UIFont.boldSystemFontOfSize(15)
let alertController = MIAlertController(
title: "I'm a googlish alert!",
message: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris",
config: googlishAlertControllerConfig
)
alertController.addButton(
MIAlertController.Button(title: "COOL", config: googlishAlertControllerLeftButtonConfig, action: {
print("cool tapped")
})
)
alertController.addButton(
MIAlertController.Button(title: "OK", config: googlishAlertControllerRightButtonConfig, action: {
print("ok tapped")
})
)
alertController.presentOn(self)
In this repository you can also find a demo.
If you like this git you can follow me here or on twitter :) @MarioIannotta
Cheers from Italy!