- Notifications
You must be signed in to change notification settings - Fork213
Customizable implementation of UIAlertViewController, UIAlertView and UIActionSheet. All in one. You can customize every detail. Make AlertView of your dream! :)
License
Friend-LGA/LGAlertView
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Customizable implementation of UIAlertViewController, UIAlertView and UIActionSheet. All in one.You can customize every detail. Make AlertView of your dream! :)
Screenshots above are just few examples that you can achieve, you are free to create any other style
| LGAlertView version | iOS version |
|---|---|
| <= 2.0.13 | >= 6.0 |
| >= 2.1.0 | >= 8.0 |
Download repository, then addLGAlertView directory to your project.
Then import header files where you need to use the library
#import"LGAlertView.h"
For swift you need to createbridging header
// BridgingHeader.h#import"LGAlertView.h"
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 onCocoaPods.
platform:ios,'8.0'use_frameworks!pod'LGAlertView'
Then import framework where you need to use the library
#import<LGAlertView/LGAlertView.h>// OR@import LGAlertView;
import LGAlertViewCarthage 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 onCarthage.
github "Friend-LGA/LGAlertView"Then import framework where you need to use the library
#import<LGAlertView/LGAlertView.h>// OR@import LGAlertView;
import LGAlertViewYou have several methods for initialization:
- (nonnullinstancetype)initWithTitle:(nullableNSString *)title message:(nullableNSString *)message style:(LGAlertViewStyle)style buttonTitles:(nullableNSArray<NSString *> *)buttonTitles cancelButtonTitle:(nullableNSString *)cancelButtonTitle destructiveButtonTitle:(nullableNSString *)destructiveButtonTitle;- (nonnullinstancetype)initWithViewAndTitle:(nullableNSString *)title message:(nullableNSString *)message style:(LGAlertViewStyle)style view:(nullable UIView *)view buttonTitles:(nullableNSArray<NSString *> *)buttonTitles cancelButtonTitle:(nullableNSString *)cancelButtonTitle destructiveButtonTitle:(nullableNSString *)destructiveButtonTitle;- (nonnullinstancetype)initWithActivityIndicatorAndTitle:(nullableNSString *)title message:(nullableNSString *)message style:(LGAlertViewStyle)style buttonTitles:(nullableNSArray<NSString *> *)buttonTitles cancelButtonTitle:(nullableNSString *)cancelButtonTitle destructiveButtonTitle:(nullableNSString *)destructiveButtonTitle;- (nonnullinstancetype)initWithProgressViewAndTitle:(nullableNSString *)title message:(nullableNSString *)message style:(LGAlertViewStyle)style progressLabelText:(nullableNSString *)progressLabelText buttonTitles:(nullableNSArray<NSString *> *)buttonTitles cancelButtonTitle:(nullableNSString *)cancelButtonTitle destructiveButtonTitle:(nullableNSString *)destructiveButtonTitle;- (nonnullinstancetype)initWithTextFieldsAndTitle:(nullableNSString *)title message:(nullableNSString *)message numberOfTextFields:(NSUInteger)numberOfTextFields textFieldsSetupHandler:(LGAlertViewTextFieldsSetupHandler)textFieldsSetupHandler buttonTitles:(nullableNSArray<NSString *> *)buttonTitles cancelButtonTitle:(nullableNSString *)cancelButtonTitle destructiveButtonTitle:(nullableNSString *)destructiveButtonTitle;
publicinit(title:String?, message:String?, style:LGAlertViewStyle, buttonTitles:[String]?,cancelButtonTitle:String?,destructiveButtonTitle:String?)publicinit(viewAndTitle title:String?, message:String?, style:LGAlertViewStyle, view:UIView?, buttonTitles:[String]?, cancelButtonTitle:String?, destructiveButtonTitle:String?)publicinit(activityIndicatorAndTitle title:String?, message:String?, style:LGAlertViewStyle, buttonTitles:[String]?, cancelButtonTitle:String?, destructiveButtonTitle:String?)publicinit(progressViewAndTitle title:String?, message:String?, style:LGAlertViewStyle, progressLabelText:String?, buttonTitles:[String]?, cancelButtonTitle:String?, destructiveButtonTitle:String?)publicinit(textFieldsAndTitle title:String?, message:String?, numberOfTextFields:UInt, textFieldsSetupHandler:LGAlertView.LGAlertViewTextFieldsSetupHandler?, buttonTitles:[String]?, cancelButtonTitle:String?, destructiveButtonTitle:String?)
More init methods you can find inLGAlertView.h
You can change properties only before you show alert view, after this to change something is impossible.
Instead of change properties for every new alert view, you can useappearance to set them all only once andnew alert views will use it by default:
[LGAlertViewappearance].tintColor = UIColor.greenColor;[LGAlertViewappearance].cancelOnTouch =NO;[LGAlertViewappearance].dismissOnAction =NO;[LGAlertViewappearance]...[LGAlertViewappearance]...
LGAlertView.appearance().tintColor=.greenLGAlertView.appearance().cancelOnTouch=falseLGAlertView.appearance().dismissOnAction=falseLGAlertView.appearance()...LGAlertView.appearance()...
By defaultLGAlertView withLGAlertViewStyleActionSheet 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:
if (@available(iOS11.0, *)) { [LGAlertViewappearance].cancelButtonOffsetY = UIApplication.sharedApplication.windows.firstObject.safeAreaInsets.bottom;}
if #available(iOS11.0,*){LGAlertView.appearance().cancelButtonOffsetY=UIApplication.sharedApplication.windows.firstObject.safeAreaInsets.bottom}
If you want to set properties for each button individually, you can use method:
- (void)setButtonPropertiesAtIndex:(NSUInteger)index handler:(void(^ _Nonnull)(LGAlertViewButtonProperties * _Nonnull properties))handler;[alertViewsetButtonPropertiesAtIndex:0handler:^(LGAlertViewButtonProperties * _Nonnull properties) { properties.titleColor = UIColor.yellowColor; properties.image = [UIImageimageNamed:@"SuperImage"];// properties...// properties...}];
openfunc setButtonPropertiesAt(_ index:UInt, handler:@escaping(LGAlertViewButtonProperties)->Swift.Void)alertView.setButtonPropertiesAt(0){(properties: LGAlertViewButtonProperties) in properties.titleColor=.yellow properties.image=UIImage(named:"SuperImage") // properties... // properties...}
You can enable and disable buttons:
alertView.cancelButtonEnabled =YES;alertView.destructiveButtonEnabled =YES;[alertViewsetButtonEnabled:YESatIndex:0];
alertView.cancelButtonEnabled=truealertView.destructiveButtonEnabled=truealertView.setButtonEnabled(true, index:0)
When you use blocks and if you need to useself inside it, then you need to make weak reference toself to avoid retain cycle:
__weaktypeof(self) wself = self;alertView.cancelHandler = ^(LGAlertView *alertView) { __strongtypeof(wself) sself = wself; [sselfsomeMethod];};
alertView.cancelHandler={[unowned self](alertView:LGAlertView)inself.someMethod()}
You can use UIBlurEffect with next properties:
UIBlurEffect *coverBlurEffect;
For example:
alertView.coverBlurEffect = [UIBlurEffecteffectWithStyle:UIBlurEffectStyleRegular];alertView.coverBlurEffect=UIBlurEffect(style:.regular)
If you want to change color of blurred view, use:
UIColor *coverColor;
For example:
alertView.coverColor = [UIColorcolorWithRed:0.0green:0.5blue:1.0alpha:0.1];
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:
CGFloat coverAlpha;
For example:
alertView.coverAlpha =0.9;To handle actions you can use blocks, delegate or notifications:
<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:(nullableNSString *)title;- (void)alertViewCancelled:(nonnull LGAlertView *)alertView;- (void)alertViewDestructed:(nonnull LGAlertView *)alertView;- (void)alertView:(nonnull LGAlertView *)alertView didDismissAfterClickedButtonAtIndex:(NSUInteger)index title:(nullableNSString *)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;
<LGAlertViewDelegate>optionalpublicfunc alertViewWillShow(_ alertView:LGAlertView)optionalpublicfunc alertViewDidShow(_ alertView:LGAlertView)optionalpublicfunc alertViewWillDismiss(_ alertView:LGAlertView)optionalpublicfunc alertViewDidDismiss(_ alertView:LGAlertView)optionalpublicfunc alertView(_ alertView:LGAlertView, clickedButtonAtIndex index:UInt, title:String?)optional publicfunc alertViewCancelled(_ alertView:LGAlertView)optional publicfunc alertViewDestructed(_ alertView:LGAlertView)optional publicfunc alertView(_ alertView:LGAlertView, didDismissAfterClickedButtonAtIndex index:UInt, title:String?)optional publicfunc alertViewDidDismissAfterCancelled(_ alertView:LGAlertView)optional publicfunc alertViewDidDismissAfterDestructed(_ alertView:LGAlertView)optional publicfunc showAnimationsForAlertView(_ alertView:LGAlertView, duration:NSTimeInterval)optional publicfunc dismissAnimationsForAlertView(_ alertView:LGAlertView, duration:NSTimeInterval)
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);
openvarwillShowHandler:((alertView:LGAlertView)->Swift.Void)?openvardidShowHandler:((alertView:LGAlertView)->Swift.Void)?openvarwillDismissHandler:((alertView:LGAlertView)->Swift.Void)?openvardidDismissHandler:((alertView:LGAlertView)->Swift.Void)?openvaractionHandler:((alertView:LGAlertView, index:NSUInteger, title:NSString)->Swift.Void)?openvarcancelHandler:((alertView:LGAlertView)->Swift.Void)?openvardestructiveHandler:((alertView:LGAlertView)->Swift.Void)?openvardidDismissAfterActionHandler:((alertView:LGAlertView, index:NSUInteger, title:NSString)->Swift.Void)?openvardidDismissAfterCancelHandler:((alertView:LGAlertView)->Swift.Void)?openvardidDismissAfterDestructiveHandler:((alertView:LGAlertView)->Swift.Void)?openvarshowAnimationsBlock:((alertView:LGAlertView, duration:NSTimeInterval)->Swift.Void)?openvardismissAnimationsBlock:((alertView:LGAlertView, duration:NSTimeInterval)->Swift.Void)?
LGAlertViewWillShowNotificationLGAlertViewDidShowNotificationLGAlertViewWillDismissNotificationLGAlertViewDidDismissNotificationLGAlertViewActionNotificationLGAlertViewCancelNotificationLGAlertViewDestructiveNotificationLGAlertViewDidDismissAfterActionNotification;LGAlertViewDidDismissAfterCancelNotification;LGAlertViewDidDismissAfterDestructiveNotification;LGAlertViewShowAnimationsNotification;LGAlertViewDismissAnimationsNotification;For more details try XcodeDemo project and seeLGAlertView.h
If you like LGAlertView, check out my other useful libraries:
- LGSideMenuControlleriOS view controller, shows left and right views by pressing button or gesture.
- LGPlusButtonsViewCustomizable iOS implementation of Floating Action Button (Google Plus Button, fab).
LGAlertView is released under the MIT license. SeeLICENSE for details.
About
Customizable implementation of UIAlertViewController, UIAlertView and UIActionSheet. All in one. You can customize every detail. Make AlertView of your dream! :)
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Contributors4
Uh oh!
There was an error while loading.Please reload this page.






































