TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Sep 2015 |
Maintained by Nealon Young.
NYAlertViewController is a replacement for UIAlertController/UIAlertView with support for content views and UI customization.
Add the files to your project manually by dragging the NYAlertViewController directory into your Xcode project.
An Objectve-C example project demonstrating customization options is included in the NYAlertViewControllerDemo directory.
// Import the class and create an NYAlertViewController instance
#import "NYAlertViewController.h"
// ...
NYAlertViewController *alertViewController = [[NYAlertViewController alloc] initWithNibName:nil bundle:nil];
// Set a title and message
alertViewController.title = NSLocalizedString(@"Custom UI", nil);
alertViewController.message = NSLocalizedString(@"Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Donec id elit non mi porta gravida at eget metus.", nil);
// Customize appearance as desired
alertViewController.buttonCornerRadius = 20.0f;
alertViewController.view.tintColor = self.view.tintColor;
alertViewController.titleFont = [UIFont fontWithName:@"AvenirNext-Bold" size:19.0f];
alertViewController.messageFont = [UIFont fontWithName:@"AvenirNext-Medium" size:16.0f];
alertViewController.buttonTitleFont = [UIFont fontWithName:@"AvenirNext-Regular" size:alertViewController.buttonTitleFont.pointSize];
alertViewController.cancelButtonTitleFont = [UIFont fontWithName:@"AvenirNext-Medium" size:alertViewController.cancelButtonTitleFont.pointSize];
alertViewController.swipeDismissalGestureEnabled = YES:
alertViewController.backgroundTapDismissalGestureEnabled = YES:
// Add alert actions
[alertViewController addAction:[NYAlertAction actionWithTitle:NSLocalizedString(@"Done", nil)
style:UIAlertActionStyleCancel
handler:^(NYAlertAction *action) {
[self dismissViewControllerAnimated:YES completion:nil];
}]];
// Present the alert view controller
[self presentViewController:alertViewController animated:YES];
import NYAlertViewController
// ...
let alertViewController = NYAlertViewController()
// Set a title and message
alertViewController.title = "Custom UI"
alertViewController.message = "Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Donec id elit non mi porta gravida at eget metus."
// Customize appearance as desired
alertViewController.buttonCornerRadius = 20.0
alertViewController.view.tintColor = self.view.tintColor
alertViewController.titleFont = UIFont(name: "AvenirNext-Bold", size: 19.0)
alertViewController.messageFont = UIFont(name: "AvenirNext-Medium", size: 16.0)
alertViewController.cancelButtonTitleFont = UIFont(name: "AvenirNext-Medium", size: 16.0)
alertViewController.cancelButtonTitleFont = UIFont(name: "AvenirNext-Medium", size: 16.0)
alertViewController.swipeDismissalGestureEnabled = true
alertViewController.backgroundTapDismissalGestureEnabled = true
// Add alert actions
let cancelAction = NYAlertAction(
title: "Done",
style: .Cancel,
handler: { (action: NYAlertAction!) -> Void in
self.dismissViewControllerAnimated(true, completion: nil)
}
)
alertViewController.addAction(cancelAction)
// Present the alert view controller
self.presentViewController(alertViewController, animated: true, completion: nil)
This project is released under the MIT License.