- July 26, 2025
- Mins Read
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.
Add pod 'NYAlertViewController'
to your Podfile, and run pod install
.
An Objective-C example project demonstrating customization options is included in the NYAlertViewControllerDemo directory.
// Import the class and create an NYAlertViewController instance
#import “NYAlertViewController.h”
// …
// Set a title and message
NSString *title = @”Location Permission”;
NSString *message = @”Set the alertViewContentView property to add custom views to the alert view”;
// Customize appearance as desired
NYAlertViewControllerConfiguration *configuration = [NYAlertViewControllerConfiguration new];
configuration.contentViewInset = UIEdgeInsetsMake(12.0f, 8.0f, 8.0f, 8.0f);
configuration.alertViewBackgroundColor = [UIColor colorWithRed:0.23f green:0.23f blue:0.27f alpha:1.0f];
configuration.separatorColor = [UIColor colorWithRed:0.16f green:0.16f blue:0.2f alpha:1.0f];
configuration.titleTextColor = [UIColor whiteColor];
configuration.messageTextColor = [UIColor whiteColor];
configuration.buttonConfiguration = [NYAlertActionConfiguration new];
configuration.buttonConfiguration.titleColor = [UIColor whiteColor];
configuration.cancelButtonConfiguration.titleColor = [UIColor whiteColor];
// Set up alert actions
NYAlertAction *cancelAction = [[NYAlertAction alloc] initWithTitle:@”Later”
style:UIAlertActionStyleCancel
handler:nil];
NYAlertAction *okAction = [[NYAlertAction alloc] initWithTitle:@”Ok”
style:UIAlertActionStyleDefault
handler:^(NYAlertAction *action) {
[self doSomething];
}]];
NYAlertViewController *alertViewController = [[NYAlertViewController alloc] initWithOptions:configuration
title:title
message:message
actions:@[cancelAction, okAction]];
// Optionally add a content view
UIImageView *iconImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@”MapIcon”]];
iconImageView.contentMode = UIViewContentModeScaleAspectFit;
[iconImageView.heightAnchor constraintEqualToConstant:60.0f].active = YES;
alertViewController.alertViewContentView = iconImageView;
// Present the alert view controller
[self presentViewController:alertViewController animated:YES completion:nil];
NavigationKit is a lightweight library which makes SwiftUI navigation super easy to use. 💻 Installation 📦 Swift Package Manager Using Swift Package Manager, add ...
An alternative SwiftUI NavigationView implementing classic stack-based navigation giving also some more control on animations and programmatic navigation. NavigationStack Installation ...
With SwiftUI Router you can power your SwiftUI app with path-based routing. By utilizing a path-based system, navigation in your app becomes ...
This package takes SwiftUI's familiar and powerful NavigationStack API and gives it superpowers, allowing you to use the same API not just ...