GitPedia

LGAlertView

Customizable implementation of UIAlertViewController, UIAlertView and UIActionSheet. All in one. You can customize every detail. Make AlertView of your dream! :)

From Friend-LGA·Updated February 23, 2026·View on GitHub·

Customizable implementation of UIAlertViewController, UIAlertView and UIActionSheet. All in one. You can customize every detail. Make AlertView of your dream! :) The project is written primarily in Objective-C, distributed under the MIT License license, first published in 2015. It has gained significant community traction with 1,063 stars and 212 forks on GitHub. Key topics include: action-sheet, actionsheet, alert-view, alert-view-controller, alertview.

Latest release: 2.4.3
September 6, 2024View Changelog →

LGAlertView

Customizable implementation of UIAlertViewController, UIAlertView and UIActionSheet. All in one.
You can customize every detail. Make AlertView of your dream! :)

Platform
CocoaPods
Carthage
License

Preview

Default Alert View

<img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Default_Alert_View/Preview.gif" height="360"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Default_Alert_View/1.png" height="360"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Default_Alert_View/2.png" height="360"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Default_Alert_View/3.png" height="360"/>
<img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Default_Alert_View/4.png" height="360"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Default_Alert_View/5.png" height="360"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Default_Alert_View/6.png" height="360"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Default_Alert_View/7.png" height="360"/>
<img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Default_Alert_View/8.png" height="360"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Default_Alert_View/9.png" height="360"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Default_Alert_View/10.png" height="360"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Default_Alert_View/11.png" height="360"/>
<img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Default_Alert_View/12.png" height="360"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Default_Alert_View/13.png" height="360"/>

Default Action Sheet

<img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Default_Action_Sheet/Preview.gif" height="360"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Default_Action_Sheet/1.png" height="360"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Default_Action_Sheet/2.png" height="360"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Default_Action_Sheet/3.png" height="360"/>
<img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Default_Action_Sheet/4.png" height="360"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Default_Action_Sheet/5.png" height="360"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Default_Action_Sheet/6.png" height="360"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Default_Action_Sheet/7.png" height="360"/>
<img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Default_Action_Sheet/8.png" height="360"/>

Blurred Alert View

<img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Blurred_Alert_View/1.png" height="360"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Blurred_Alert_View/2.png" height="360"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Blurred_Alert_View/3.png" height="360"/>

<img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Blurred_Alert_View/4.png" height="360"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Blurred_Alert_View/5.png" height="360"/>

Blurred Action Sheet

<img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Blurred_Action_Sheet/1.png" height="360"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Blurred_Action_Sheet/2.png" height="360"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Blurred_Action_Sheet/3.png" height="360"/>

<img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Blurred_Action_Sheet/4.png" height="360"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Blurred_Action_Sheet/5.png" height="360"/>

Custom Alert View

<img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Custom_Alert_View/1.png" height="360"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Custom_Alert_View/2.png" height="360"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Custom_Alert_View/3.png" height="360"/>

Custom Action Sheet

<img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Custom_Action_Sheet/1.png" height="360"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Custom_Action_Sheet/2.png" height="360"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/e86caa0a37236d03642747a379f4a92f5384c317/LGAlertView/Custom_Action_Sheet/3.png" height="360"/>

Screenshots above are just few examples that you can achieve, you are free to create any other style

Installation

LGAlertView versioniOS version
<= 2.0.13>= 6.0
>= 2.1.0>= 8.0

With source code

Download repository, then add LGAlertView directory to your project.

Then import header files where you need to use the library

Objective-C
objective
#import "LGAlertView.h"
Swift

For swift you need to create bridging header

objective
// BridgingHeader.h #import "LGAlertView.h"

With CocoaPods

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries in your projects. To install with cocoaPods, follow the "Get Started" section on CocoaPods.

Podfile

ruby
platform :ios, '8.0' use_frameworks! pod 'LGAlertView'

Then import framework where you need to use the library

Objective-C
objective
#import <LGAlertView/LGAlertView.h> // OR @import LGAlertView;
Swift
swift
import LGAlertView

With Carthage

Carthage is a lightweight dependency manager for Swift and Objective-C. It leverages CocoaTouch modules and is less invasive than CocoaPods. To install with carthage, follow the instruction on Carthage.

Cartfile

github "Friend-LGA/LGAlertView"

Then import framework where you need to use the library

Objective-C
objective
#import <LGAlertView/LGAlertView.h> // OR @import LGAlertView;
Swift
swift
import LGAlertView

Usage

Initialization

You have several methods for initialization:

Objective-C
objective
- (nonnull instancetype)initWithTitle:(nullable NSString *)title message:(nullable NSString *)message style:(LGAlertViewStyle)style buttonTitles:(nullable NSArray<NSString *> *)buttonTitles cancelButtonTitle:(nullable NSString *)cancelButtonTitle destructiveButtonTitle:(nullable NSString *)destructiveButtonTitle; - (nonnull instancetype)initWithViewAndTitle:(nullable NSString *)title message:(nullable NSString *)message style:(LGAlertViewStyle)style view:(nullable UIView *)view buttonTitles:(nullable NSArray<NSString *> *)buttonTitles cancelButtonTitle:(nullable NSString *)cancelButtonTitle destructiveButtonTitle:(nullable NSString *)destructiveButtonTitle; - (nonnull instancetype)initWithActivityIndicatorAndTitle:(nullable NSString *)title message:(nullable NSString *)message style:(LGAlertViewStyle)style buttonTitles:(nullable NSArray<NSString *> *)buttonTitles cancelButtonTitle:(nullable NSString *)cancelButtonTitle destructiveButtonTitle:(nullable NSString *)destructiveButtonTitle; - (nonnull instancetype)initWithProgressViewAndTitle:(nullable NSString *)title message:(nullable NSString *)message style:(LGAlertViewStyle)style progressLabelText:(nullable NSString *)progressLabelText buttonTitles:(nullable NSArray<NSString *> *)buttonTitles cancelButtonTitle:(nullable NSString *)cancelButtonTitle destructiveButtonTitle:(nullable NSString *)destructiveButtonTitle; - (nonnull instancetype)initWithTextFieldsAndTitle:(nullable NSString *)title message:(nullable NSString *)message numberOfTextFields:(NSUInteger)numberOfTextFields textFieldsSetupHandler:(LGAlertViewTextFieldsSetupHandler)textFieldsSetupHandler buttonTitles:(nullable NSArray<NSString *> *)buttonTitles cancelButtonTitle:(nullable NSString *)cancelButtonTitle destructiveButtonTitle:(nullable NSString *)destructiveButtonTitle;
Swift
swift
public init(title: String?, message: String?, style: LGAlertViewStyle, buttonTitles: [String]?, cancelButtonTitle: String?, destructiveButtonTitle: String?) public init(viewAndTitle title: String?, message: String?, style: LGAlertViewStyle, view: UIView?, buttonTitles: [String]?, cancelButtonTitle: String?, destructiveButtonTitle: String?) public init(activityIndicatorAndTitle title: String?, message: String?, style: LGAlertViewStyle, buttonTitles: [String]?, cancelButtonTitle: String?, destructiveButtonTitle: String?) public init(progressViewAndTitle title: String?, message: String?, style: LGAlertViewStyle, progressLabelText: String?, buttonTitles: [String]?, cancelButtonTitle: String?, destructiveButtonTitle: String?) public init(textFieldsAndTitle title: String?, message: String?, numberOfTextFields: UInt, textFieldsSetupHandler: LGAlertView.LGAlertViewTextFieldsSetupHandler?, buttonTitles: [String]?, cancelButtonTitle: String?, destructiveButtonTitle: String?)

More init methods you can find in LGAlertView.h

Setup

You can change properties only before you show alert view, after this to change something is impossible.

Appearance

Instead of change properties for every new alert view, you can use appearance to set them all only once and
new alert views will use it by default:

Objective-C
objective
[LGAlertView appearance].tintColor = UIColor.greenColor; [LGAlertView appearance].cancelOnTouch = NO; [LGAlertView appearance].dismissOnAction = NO; [LGAlertView appearance]... [LGAlertView appearance]...
Swift
swift
LGAlertView.appearance().tintColor = .green LGAlertView.appearance().cancelOnTouch = false LGAlertView.appearance().dismissOnAction = false LGAlertView.appearance()... LGAlertView.appearance()...

Action Sheet Safe Area

By default LGAlertView with LGAlertViewStyleActionSheet style doesn't use safe area insets.
So for now it's up to you to set the offset, and it as easy as this:

Objective-C
objective
if (@available(iOS 11.0, *)) { [LGAlertView appearance].cancelButtonOffsetY = UIApplication.sharedApplication.windows.firstObject.safeAreaInsets.bottom; }
Swift
swift
if #available(iOS 11.0, *) { LGAlertView.appearance().cancelButtonOffsetY = UIApplication.sharedApplication.windows.firstObject.safeAreaInsets.bottom }

Buttons

If you want to set properties for each button individually, you can use method:

Objective-C
objective
- (void)setButtonPropertiesAtIndex:(NSUInteger)index handler:(void(^ _Nonnull)(LGAlertViewButtonProperties * _Nonnull properties))handler; [alertView setButtonPropertiesAtIndex:0 handler:^(LGAlertViewButtonProperties * _Nonnull properties) { properties.titleColor = UIColor.yellowColor; properties.image = [UIImage imageNamed:@"SuperImage"]; // properties... // properties... }];
Swift
swift
open func setButtonPropertiesAt(_ index: UInt, handler: @escaping (LGAlertViewButtonProperties) -> Swift.Void) alertView.setButtonPropertiesAt(0) { (properties: LGAlertViewButtonProperties) in properties.titleColor = .yellow properties.image = UIImage(named: "SuperImage") // properties... // properties... }

Enable / Disable

You can enable and disable buttons:

Objective-C
objective
alertView.cancelButtonEnabled = YES; alertView.destructiveButtonEnabled = YES; [alertView setButtonEnabled:YES atIndex:0];
Swift
swift
alertView.cancelButtonEnabled = true alertView.destructiveButtonEnabled = true alertView.setButtonEnabled(true, index: 0)

Retain Cycle

When you use blocks and if you need to use self inside it, then you need to make weak reference to self to avoid retain cycle:

Objective-C
objective
__weak typeof(self) wself = self; alertView.cancelHandler = ^(LGAlertView *alertView) { __strong typeof(wself) sself = wself; [sself someMethod]; };
Swift
swift
alertView.cancelHandler = { [unowned self](alertView: LGAlertView) in self.someMethod() }

Blur

You can use UIBlurEffect with next properties:

objective
UIBlurEffect *coverBlurEffect;

For example:

Objective-C
objective
alertView.coverBlurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleRegular];
Swift
swift
alertView.coverBlurEffect = UIBlurEffect(style: .regular)

If you want to change color of blurred view, use:

objective
UIColor *coverColor;

For example:

Objective-C
objective
alertView.coverColor = [UIColor colorWithRed:0.0 green:0.5 blue:1.0 alpha:0.1];
Swift
swift
alertView.coverColor = UIColor(red: 0.0, green: 0.5, blue: 1.0, alpha: 0.1)

If you want to change intensity of blurred view, use:

objective
CGFloat coverAlpha;

For example:

objective
alertView.coverAlpha = 0.9;

Handle actions

To handle actions you can use blocks, delegate or notifications:

Delegate

Objective-C
objective
<LGAlertViewDelegate> @optional - (void)alertViewWillShow:(nonnull LGAlertView *)alertView; - (void)alertViewDidShow:(nonnull LGAlertView *)alertView; - (void)alertViewWillDismiss:(nonnull LGAlertView *)alertView; - (void)alertViewDidDismiss:(nonnull LGAlertView *)alertView; - (void)alertView:(nonnull LGAlertView *)alertView clickedButtonAtIndex:(NSUInteger)index title:(nullable NSString *)title; - (void)alertViewCancelled:(nonnull LGAlertView *)alertView; - (void)alertViewDestructed:(nonnull LGAlertView *)alertView; - (void)alertView:(nonnull LGAlertView *)alertView didDismissAfterClickedButtonAtIndex:(NSUInteger)index title:(nullable NSString *)title; - (void)alertViewDidDismissAfterCancelled:(nonnull LGAlertView *)alertView; - (void)alertViewDidDismissAfterDestructed:(nonnull LGAlertView *)alertView; - (void)showAnimationsForAlertView:(nonnull LGAlertView *)alertView duration:(NSTimeInterval)duration; - (void)dismissAnimationsForAlertView:(nonnull LGAlertView *)alertView duration:(NSTimeInterval)duration;
Swift
swift
<LGAlertViewDelegate> optional public func alertViewWillShow(_ alertView: LGAlertView) optional public func alertViewDidShow(_ alertView: LGAlertView) optional public func alertViewWillDismiss(_ alertView: LGAlertView) optional public func alertViewDidDismiss(_ alertView: LGAlertView) optional public func alertView(_ alertView: LGAlertView, clickedButtonAtIndex index: UInt, title: String?) optional public func alertViewCancelled(_ alertView: LGAlertView) optional public func alertViewDestructed(_ alertView: LGAlertView) optional public func alertView(_ alertView: LGAlertView, didDismissAfterClickedButtonAtIndex index: UInt, title: String?) optional public func alertViewDidDismissAfterCancelled(_ alertView: LGAlertView) optional public func alertViewDidDismissAfterDestructed(_ alertView: LGAlertView) optional public func showAnimationsForAlertView(_ alertView: LGAlertView, duration: NSTimeInterval) optional public func dismissAnimationsForAlertView(_ alertView: LGAlertView, duration: NSTimeInterval)

Blocks

Objective-C
objective
void(^ _Nullable willShowHandler)(LGAlertView * _Nonnull alertView); void(^ _Nullable willShowHandler)(LGAlertView * _Nonnull alertView); void(^ _Nullable didShowHandler)(LGAlertView * _Nonnull alertView); void(^ _Nullable willDismissHandler)(LGAlertView * _Nonnull alertView); void(^ _Nullable didDismissHandler)(LGAlertView * _Nonnull alertView); void(^ _Nullable actionHandler)(LGAlertView * _Nonnull alertView, NSUInteger index, NSString * _Nullable title); void(^ _Nullable cancelHandler)(LGAlertView * _Nonnull alertView); void(^ _Nullable destructiveHandler)(LGAlertView * _Nonnull alertView); void(^ _Nullable didDismissAfterActionHandler)(LGAlertView * _Nonnull alertView, NSUInteger index, NSString * _Nullable title); void(^ _Nullable didDismissAfterCancelHandler)(LGAlertView * _Nonnull alertView); void(^ _Nullable didDismissAfterDestructiveHandler)(LGAlertView * _Nonnull alertView); void(^ _Nullable showAnimationsBlock)(LGAlertView * _Nonnull alertView, NSTimeInterval duration); void(^ _Nullable dismissAnimationsBlock)(LGAlertView * _Nonnull alertView, NSTimeInterval duration);
Swift
swift
open var willShowHandler: ((alertView: LGAlertView) -> Swift.Void)? open var didShowHandler: ((alertView: LGAlertView) -> Swift.Void)? open var willDismissHandler: ((alertView: LGAlertView) -> Swift.Void)? open var didDismissHandler: ((alertView: LGAlertView) -> Swift.Void)? open var actionHandler: ((alertView: LGAlertView, index: NSUInteger, title: NSString) -> Swift.Void)? open var cancelHandler: ((alertView: LGAlertView) -> Swift.Void)? open var destructiveHandler: ((alertView: LGAlertView) -> Swift.Void)? open var didDismissAfterActionHandler: ((alertView: LGAlertView, index: NSUInteger, title: NSString) -> Swift.Void)? open var didDismissAfterCancelHandler: ((alertView: LGAlertView) -> Swift.Void)? open var didDismissAfterDestructiveHandler: ((alertView: LGAlertView) -> Swift.Void)? open var showAnimationsBlock: ((alertView: LGAlertView, duration: NSTimeInterval) -> Swift.Void)? open var dismissAnimationsBlock: ((alertView: LGAlertView, duration: NSTimeInterval) -> Swift.Void)?

Notifications

LGAlertViewWillShowNotification
LGAlertViewDidShowNotification

LGAlertViewWillDismissNotification
LGAlertViewDidDismissNotification

LGAlertViewActionNotification
LGAlertViewCancelNotification
LGAlertViewDestructiveNotification

LGAlertViewDidDismissAfterActionNotification;
LGAlertViewDidDismissAfterCancelNotification;
LGAlertViewDidDismissAfterDestructiveNotification;

LGAlertViewShowAnimationsNotification;
LGAlertViewDismissAnimationsNotification;

More

For more details try Xcode Demo project and see LGAlertView.h

Frameworks

If you like LGAlertView, check out my other useful libraries:

  • LGSideMenuController
    iOS view controller, shows left and right views by pressing button or gesture.
  • LGPlusButtonsView
    Customizable iOS implementation of Floating Action Button (Google Plus Button, fab).

License

LGAlertView is released under the MIT license. See LICENSE for details.

Contributors

Showing top 4 contributors by commit count.

View all contributors on GitHub →

This article is auto-generated from Friend-LGA/LGAlertView via the GitHub API.Last fetched: 6/14/2026