123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823 |
- //
- // LGAlertView.h
- // LGAlertView
- //
- //
- // The MIT License (MIT)
- //
- // Copyright © 2015 Grigory Lutkov <Friend.LGA@gmail.com>
- // (https://github.com/Friend-LGA/LGAlertView)
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the "Software"), to deal
- // in the Software without restriction, including without limitation the rights
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- // copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in all
- // copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- // SOFTWARE.
- //
- #import <UIKit/UIKit.h>
- #import "LGAlertViewButtonProperties.h"
- #import "LGAlertViewShared.h"
- @class LGAlertView;
- @protocol LGAlertViewDelegate;
- #pragma mark - Constants
- extern NSString * _Nonnull const LGAlertViewWillShowNotification;
- extern NSString * _Nonnull const LGAlertViewDidShowNotification;
- extern NSString * _Nonnull const LGAlertViewWillDismissNotification;
- extern NSString * _Nonnull const LGAlertViewDidDismissNotification;
- extern NSString * _Nonnull const LGAlertViewActionNotification;
- extern NSString * _Nonnull const LGAlertViewCancelNotification;
- extern NSString * _Nonnull const LGAlertViewDestructiveNotification;
- extern NSString * _Nonnull const LGAlertViewDidDismissAfterActionNotification;
- extern NSString * _Nonnull const LGAlertViewDidDismissAfterCancelNotification;
- extern NSString * _Nonnull const LGAlertViewDidDismissAfterDestructiveNotification;
- /** You can use this notification to add some custom animations */
- extern NSString * _Nonnull const LGAlertViewShowAnimationsNotification;
- /** You can use this notification to add some custom animations */
- extern NSString * _Nonnull const LGAlertViewDismissAnimationsNotification;
- extern NSString * _Nonnull const kLGAlertViewAnimationDuration;
- #pragma mark - Types
- typedef void (^ _Nullable LGAlertViewCompletionHandler)();
- typedef void (^ _Nullable LGAlertViewHandler)(LGAlertView * _Nonnull alertView);
- typedef void (^ _Nullable LGAlertViewActionHandler)(LGAlertView * _Nonnull alertView, NSUInteger index, NSString * _Nullable title);
- typedef void (^ _Nullable LGAlertViewTextFieldsSetupHandler)(UITextField * _Nonnull textField, NSUInteger index);
- typedef void (^ _Nullable LGAlertViewAnimationsBlock)(LGAlertView * _Nonnull alertView, NSTimeInterval duration);
- typedef NS_ENUM(NSUInteger, LGAlertViewStyle) {
- LGAlertViewStyleAlert = 0,
- LGAlertViewStyleActionSheet = 1
- };
- typedef NS_ENUM(NSUInteger, LGAlertViewWindowLevel) {
- LGAlertViewWindowLevelAboveStatusBar = 0,
- LGAlertViewWindowLevelBelowStatusBar = 1
- };
- #pragma mark -
- @interface LGAlertView : NSObject <UIAppearance>
- /** Is action "show" already had been executed */
- @property (assign, nonatomic, readonly, getter=isShowing) BOOL showing;
- /** Is alert view visible right now */
- @property (assign, nonatomic, readonly, getter=isVisible) BOOL visible;
- @property (assign, nonatomic, readonly) LGAlertViewStyle style;
- /** Default is LGAlertViewWindowLevelAboveStatusBar */
- @property (assign, nonatomic) LGAlertViewWindowLevel windowLevel UI_APPEARANCE_SELECTOR;
- /**
- Default:
- if (alert with activityIndicator || progressView || textFields) then NO
- else YES
- */
- @property (assign, nonatomic, getter=isCancelOnTouch) BOOL cancelOnTouch UI_APPEARANCE_SELECTOR;
- /**
- Dismiss alert view on action, cancel and destructive
- Default is YES
- */
- @property (assign, nonatomic, getter=isDismissOnAction) BOOL dismissOnAction UI_APPEARANCE_SELECTOR;
- @property (copy, nonatomic, readonly, nullable) NSArray *textFieldsArray;
- /** View that you associate to alert view while initialization */
- @property (strong, nonatomic, readonly, nullable) UIView *innerView;
- /** Default is 0 */
- @property (assign, nonatomic) NSInteger tag;
- #pragma mark - Style properties
- /**
- Set colors of buttons title and highlighted background, cancel button title and highlighted background, activity indicator and progress view
- Default is [UIColor colorWithRed:0.0 green:0.5 blue:1.0 alpha:1.0]
- */
- @property (strong, nonatomic, nullable) UIColor *tintColor UI_APPEARANCE_SELECTOR;
- /**
- Color hides main view when alert view is showing
- Default is [UIColor colorWithWhite:0.0 alpha:0.35]
- */
- @property (strong, nonatomic, nullable) UIColor *coverColor UI_APPEARANCE_SELECTOR;
- /** Default is nil */
- @property (strong, nonatomic, nullable) UIBlurEffect *coverBlurEffect UI_APPEARANCE_SELECTOR;
- /** Default is 1.0 */
- @property (assign, nonatomic) CGFloat coverAlpha UI_APPEARANCE_SELECTOR;
- /** Default is UIColor.whiteColor */
- @property (strong, nonatomic, nullable) UIColor *backgroundColor UI_APPEARANCE_SELECTOR;
- /** Default is nil */
- @property (strong, nonatomic, nullable) UIBlurEffect *backgroundBlurEffect UI_APPEARANCE_SELECTOR;
- /**
- Default:
- if (style == LGAlertViewStyleAlert || iOS < 9.0) then 44.0
- else 56.0
- */
- @property (assign, nonatomic) CGFloat buttonsHeight UI_APPEARANCE_SELECTOR;
- /** Default is 44.0 */
- @property (assign, nonatomic) CGFloat textFieldsHeight UI_APPEARANCE_SELECTOR;
- /**
- Top and bottom offsets from borders of the screen
- Default is 8.0
- */
- @property (assign, nonatomic) CGFloat offsetVertical UI_APPEARANCE_SELECTOR;
- /**
- Offset between cancel button and main view when style is LGAlertViewStyleActionSheet
- Default is 8.0
- */
- @property (assign, nonatomic) CGFloat cancelButtonOffsetY UI_APPEARANCE_SELECTOR;
- /** Default is NSNotFound */
- @property (assign, nonatomic) CGFloat heightMax UI_APPEARANCE_SELECTOR;
- /**
- Default:
- if (style == LGAlertViewStyleAlert) then 280.0
- else if (iPad) then 304.0
- else window.width - 16.0
- */
- @property (assign, nonatomic) CGFloat width UI_APPEARANCE_SELECTOR;
- /** Default is [UIColor colorWithWhite:0.85 alpha:1.0] */
- @property (strong, nonatomic, nullable) UIColor *separatorsColor UI_APPEARANCE_SELECTOR;
- /** Default is UIScrollViewIndicatorStyleBlack */
- @property (assign, nonatomic) UIScrollViewIndicatorStyle indicatorStyle UI_APPEARANCE_SELECTOR;
- /** Default is NO */
- @property (assign, nonatomic, getter=isShowsVerticalScrollIndicator) BOOL showsVerticalScrollIndicator UI_APPEARANCE_SELECTOR;
- /** Default is NO */
- @property (assign, nonatomic, getter=isPadShowsActionSheetFromBottom) BOOL padShowsActionSheetFromBottom UI_APPEARANCE_SELECTOR;
- /** Default is NO */
- @property (assign, nonatomic, getter=isOneRowOneButton) BOOL oneRowOneButton UI_APPEARANCE_SELECTOR;
- /** Default is YES */
- @property (assign, nonatomic) BOOL shouldDismissAnimated UI_APPEARANCE_SELECTOR;
- #pragma marl - Layer properties
- /**
- Default:
- if (iOS < 9.0) then 6.0
- else 12.0
- */
- @property (assign, nonatomic) CGFloat layerCornerRadius UI_APPEARANCE_SELECTOR;
- /** Default is nil */
- @property (strong, nonatomic, nullable) UIColor *layerBorderColor UI_APPEARANCE_SELECTOR;
- /** Default is 0.0 */
- @property (assign, nonatomic) CGFloat layerBorderWidth UI_APPEARANCE_SELECTOR;
- /** Default is nil */
- @property (strong, nonatomic, nullable) UIColor *layerShadowColor UI_APPEARANCE_SELECTOR;
- /** Default is 0.0 */
- @property (assign, nonatomic) CGFloat layerShadowRadius UI_APPEARANCE_SELECTOR;
- /** Default is CGPointZero */
- @property (assign, nonatomic) CGPoint layerShadowOffset UI_APPEARANCE_SELECTOR;
- #pragma mark - Animation properties
- /** Default is 0.5 */
- @property (assign, nonatomic) NSTimeInterval animationDuration UI_APPEARANCE_SELECTOR;
- /**
- Only if (style == LGAlertViewStyleAlert)
- Default is 1.2
- */
- @property (assign, nonatomic) CGFloat initialScale UI_APPEARANCE_SELECTOR;
- /**
- Only if (style == LGAlertViewStyleAlert)
- Default is 0.95
- */
- @property (assign, nonatomic) CGFloat finalScale UI_APPEARANCE_SELECTOR;
- #pragma mark - Title properties
- @property (copy, nonatomic, readonly, nullable) NSString *title;
- /**
- Default:
- if (style == LGAlertViewStyleAlert) then UIColor.blackColor
- else UIColor.grayColor
- */
- @property (strong, nonatomic, nullable) UIColor *titleTextColor UI_APPEARANCE_SELECTOR;
- /** Default is NSTextAlignmentCenter */
- @property (assign, nonatomic) NSTextAlignment titleTextAlignment UI_APPEARANCE_SELECTOR;
- /**
- Default:
- if (style == LGAlertViewStyleAlert) then [UIFont boldSystemFontOfSize:18.0]
- else [UIFont boldSystemFontOfSize:14.0]
- */
- @property (strong, nonatomic, nullable) UIFont *titleFont UI_APPEARANCE_SELECTOR;
- #pragma mark - Message properties
- @property (copy, nonatomic, readonly, nullable) NSString *message;
- /**
- Default:
- if (style == LGAlertViewStyleAlert) then UIColor.blackColor
- else UIColor.grayColor
- */
- @property (strong, nonatomic, nullable) UIColor *messageTextColor UI_APPEARANCE_SELECTOR;
- /** Default is NSTextAlignmentCenter */
- @property (assign, nonatomic) NSTextAlignment messageTextAlignment UI_APPEARANCE_SELECTOR;
- /** Default is [UIFont systemFontOfSize:14.0] */
- @property (strong, nonatomic, nullable) UIFont *messageFont UI_APPEARANCE_SELECTOR;
- #pragma mark - Buttons properties
- @property (copy, nonatomic, readonly, nullable) NSArray *buttonTitles;
- /** Default is YES */
- @property (assign, nonatomic, getter=isCancelButtonEnabled) BOOL buttonsEnabled;
- @property (copy, nonatomic, nullable) NSArray *buttonsIconImages;
- @property (copy, nonatomic, nullable) NSArray *buttonsIconImagesHighlighted;
- @property (copy, nonatomic, nullable) NSArray *buttonsIconImagesDisabled;
- /** Default is tintColor */
- @property (strong, nonatomic, nullable) UIColor *buttonsTitleColor UI_APPEARANCE_SELECTOR;
- /** Default is UIColor.whiteColor */
- @property (strong, nonatomic, nullable) UIColor *buttonsTitleColorHighlighted UI_APPEARANCE_SELECTOR;
- /** Default is UIColor.grayColor */
- @property (strong, nonatomic, nullable) UIColor *buttonsTitleColorDisabled UI_APPEARANCE_SELECTOR;
- /** Default is NSTextAlignmentCenter */
- @property (assign, nonatomic) NSTextAlignment buttonsTextAlignment UI_APPEARANCE_SELECTOR;
- /** Default is [UIFont systemFontOfSize:18.0] */
- @property (strong, nonatomic, nullable) UIFont *buttonsFont UI_APPEARANCE_SELECTOR;
- /** Default is UIColor.clearColor */
- @property (strong, nonatomic, nullable) UIColor *buttonsBackgroundColor UI_APPEARANCE_SELECTOR;
- /** Default is tintColor */
- @property (strong, nonatomic, nullable) UIColor *buttonsBackgroundColorHighlighted UI_APPEARANCE_SELECTOR;
- /** Default is UIColor.clearColor */
- @property (strong, nonatomic, nullable) UIColor *buttonsBackgroundColorDisabled UI_APPEARANCE_SELECTOR;
- /** Default is 1 */
- @property (assign, nonatomic) NSUInteger buttonsNumberOfLines UI_APPEARANCE_SELECTOR;
- /** Default is NSLineBreakByTruncatingMiddle */
- @property (assign, nonatomic) NSLineBreakMode buttonsLineBreakMode UI_APPEARANCE_SELECTOR;
- /** Default is 14.0 / 18.0 */
- @property (assign, nonatomic) CGFloat buttonsMinimumScaleFactor UI_APPEARANCE_SELECTOR;
- /** Default is YES */
- @property (assign, nonatomic, getter=isButtonsAdjustsFontSizeToFitWidth) BOOL buttonsAdjustsFontSizeToFitWidth UI_APPEARANCE_SELECTOR;
- /** Default is LGAlertViewButtonIconPositionLeft */
- @property (assign, nonatomic) LGAlertViewButtonIconPosition buttonsIconPosition UI_APPEARANCE_SELECTOR;
- #pragma mark - Cancel button properties
- @property (copy, nonatomic, readonly, nullable) NSString *cancelButtonTitle;
- /** Default is YES */
- @property (assign, nonatomic, getter=isCancelButtonEnabled) BOOL cancelButtonEnabled;
- @property (strong, nonatomic, nullable) UIImage *cancelButtonIconImage;
- @property (strong, nonatomic, nullable) UIImage *cancelButtonIconImageHighlighted;
- @property (strong, nonatomic, nullable) UIImage *cancelButtonIconImageDisabled;
- /** Default is tintColor */
- @property (strong, nonatomic, nullable) UIColor *cancelButtonTitleColor UI_APPEARANCE_SELECTOR;
- /** Default is UIColor.whiteColor */
- @property (strong, nonatomic, nullable) UIColor *cancelButtonTitleColorHighlighted UI_APPEARANCE_SELECTOR;
- /** Default is UIColor.grayColor */
- @property (strong, nonatomic, nullable) UIColor *cancelButtonTitleColorDisabled UI_APPEARANCE_SELECTOR;
- /** Default is NSTextAlignmentCenter */
- @property (assign, nonatomic) NSTextAlignment cancelButtonTextAlignment UI_APPEARANCE_SELECTOR;
- /** Default is [UIFont boldSystemFontOfSize:18.0] */
- @property (strong, nonatomic, nullable) UIFont *cancelButtonFont UI_APPEARANCE_SELECTOR;
- /** Default is UIColor.clearColor */
- @property (strong, nonatomic, nullable) UIColor *cancelButtonBackgroundColor UI_APPEARANCE_SELECTOR;
- /** Default is tintColor */
- @property (strong, nonatomic, nullable) UIColor *cancelButtonBackgroundColorHighlighted UI_APPEARANCE_SELECTOR;
- /** Default is UIColor.clearColor */
- @property (strong, nonatomic, nullable) UIColor *cancelButtonBackgroundColorDisabled UI_APPEARANCE_SELECTOR;
- /** Default is 1 */
- @property (assign, nonatomic) NSUInteger cancelButtonNumberOfLines UI_APPEARANCE_SELECTOR;
- /** Default is NSLineBreakByTruncatingMiddle */
- @property (assign, nonatomic) NSLineBreakMode cancelButtonLineBreakMode UI_APPEARANCE_SELECTOR;
- /** Default is 14.0 / 18.0 */
- @property (assign, nonatomic) CGFloat cancelButtonMinimumScaleFactor UI_APPEARANCE_SELECTOR;
- /** Default is YES */
- @property (assign, nonatomic, getter=isCancelButtonAdjustsFontSizeToFitWidth) BOOL cancelButtonAdjustsFontSizeToFitWidth UI_APPEARANCE_SELECTOR;
- /** Default is LGAlertViewButtonIconPositionLeft */
- @property (assign, nonatomic) LGAlertViewButtonIconPosition cancelButtonIconPosition UI_APPEARANCE_SELECTOR;
- #pragma mark - Destructive button properties
- @property (copy, nonatomic, readonly, nullable) NSString *destructiveButtonTitle;
- /** Default is YES */
- @property (assign, nonatomic, getter=isDestructiveButtonEnabled) BOOL destructiveButtonEnabled;
- @property (strong, nonatomic, nullable) UIImage *destructiveButtonIconImage;
- @property (strong, nonatomic, nullable) UIImage *destructiveButtonIconImageHighlighted;
- @property (strong, nonatomic, nullable) UIImage *destructiveButtonIconImageDisabled;
- /** Default is UIColor.redColor */
- @property (strong, nonatomic, nullable) UIColor *destructiveButtonTitleColor UI_APPEARANCE_SELECTOR;
- /** Default is UIColor.whiteColor */
- @property (strong, nonatomic, nullable) UIColor *destructiveButtonTitleColorHighlighted UI_APPEARANCE_SELECTOR;
- /** Default is UIColor.grayColor */
- @property (strong, nonatomic, nullable) UIColor *destructiveButtonTitleColorDisabled UI_APPEARANCE_SELECTOR;
- /** Default is NSTextAlignmentCenter */
- @property (assign, nonatomic) NSTextAlignment destructiveButtonTextAlignment UI_APPEARANCE_SELECTOR;
- /** Default is [UIFont systemFontOfSize:18.0] */
- @property (strong, nonatomic, nullable) UIFont *destructiveButtonFont UI_APPEARANCE_SELECTOR;
- /** Default is UIColor.clearColor */
- @property (strong, nonatomic, nullable) UIColor *destructiveButtonBackgroundColor UI_APPEARANCE_SELECTOR;
- /** Default is UIColor.redColor */
- @property (strong, nonatomic, nullable) UIColor *destructiveButtonBackgroundColorHighlighted UI_APPEARANCE_SELECTOR;
- /** Default is UIColor.clearColor */
- @property (strong, nonatomic, nullable) UIColor *destructiveButtonBackgroundColorDisabled UI_APPEARANCE_SELECTOR;
- /** Default is 1 */
- @property (assign, nonatomic) NSUInteger destructiveButtonNumberOfLines UI_APPEARANCE_SELECTOR;
- /** Default is NSLineBreakByTruncatingMiddle */
- @property (assign, nonatomic) NSLineBreakMode destructiveButtonLineBreakMode UI_APPEARANCE_SELECTOR;
- /** Default is 14.0 / 18.0 */
- @property (assign, nonatomic) CGFloat destructiveButtonMinimumScaleFactor UI_APPEARANCE_SELECTOR;
- /** Default is YES */
- @property (assign, nonatomic, getter=isDestructiveButtonAdjustsFontSizeToFitWidth) BOOL destructiveButtonAdjustsFontSizeToFitWidth UI_APPEARANCE_SELECTOR;
- /** Default is LGAlertViewButtonIconPositionLeft */
- @property (assign, nonatomic) LGAlertViewButtonIconPosition destructiveButtonIconPosition UI_APPEARANCE_SELECTOR;
- #pragma mark - Activity indicator properties
- /** Default is UIActivityIndicatorViewStyleWhiteLarge */
- @property (assign, nonatomic) UIActivityIndicatorViewStyle activityIndicatorViewStyle UI_APPEARANCE_SELECTOR;
- /** Default is tintColor */
- @property (strong, nonatomic, nullable) UIColor *activityIndicatorViewColor UI_APPEARANCE_SELECTOR;
- #pragma mark - Progress view properties
- @property (assign, nonatomic) float progress;
- /** Default is tintColor */
- @property (strong, nonatomic, nullable) UIColor *progressViewProgressTintColor UI_APPEARANCE_SELECTOR;
- /** Default is [UIColor colorWithWhite:0.8 alpha:1.0] */
- @property (strong, nonatomic, nullable) UIColor *progressViewTrackTintColor UI_APPEARANCE_SELECTOR;
- /** Default is nil */
- @property (strong, nonatomic, nullable) UIImage *progressViewProgressImage UI_APPEARANCE_SELECTOR;
- /** Default is nil */
- @property (strong, nonatomic, nullable) UIImage *progressViewTrackImage UI_APPEARANCE_SELECTOR;
- #pragma mark - Progress label properties
- @property (strong, nonatomic, nullable) NSString *progressLabelText;
- /** Default is UIColor.blackColor */
- @property (strong, nonatomic, nullable) UIColor *progressLabelTextColor UI_APPEARANCE_SELECTOR;
- /** Defailt is NSTextAlignmentCenter */
- @property (assign, nonatomic) NSTextAlignment progressLabelTextAlignment UI_APPEARANCE_SELECTOR;
- /** Default is [UIFont systemFontOfSize:14.0] */
- @property (strong, nonatomic, nullable) UIFont *progressLabelFont UI_APPEARANCE_SELECTOR;
- /** Default is 1 */
- @property (assign, nonatomic) NSUInteger progressLabelNumberOfLines UI_APPEARANCE_SELECTOR;
- /** Default is NSLineBreakByTruncatingTail */
- @property (assign, nonatomic) NSLineBreakMode progressLabelLineBreakMode UI_APPEARANCE_SELECTOR;
- #pragma mark - Text fields properties
- /** Default is [UIColor colorWithWhite:0.97 alpha:1.0] */
- @property (strong, nonatomic, nullable) UIColor *textFieldsBackgroundColor UI_APPEARANCE_SELECTOR;
- /** Default is UIColor.blackColor */
- @property (strong, nonatomic, nullable) UIColor *textFieldsTextColor UI_APPEARANCE_SELECTOR;
- /** Default is [UIFont systemFontOfSize:16.0] */
- @property (strong, nonatomic, nullable) UIFont *textFieldsFont UI_APPEARANCE_SELECTOR;
- /** Default is NSTextAlignmentLeft */
- @property (assign, nonatomic) NSTextAlignment textFieldsTextAlignment UI_APPEARANCE_SELECTOR;
- /** Default is NO */
- @property (assign, nonatomic) BOOL textFieldsClearsOnBeginEditing UI_APPEARANCE_SELECTOR;
- /** Default is NO */
- @property (assign, nonatomic) BOOL textFieldsAdjustsFontSizeToFitWidth UI_APPEARANCE_SELECTOR;
- /** Default is 12.0 */
- @property (assign, nonatomic) CGFloat textFieldsMinimumFontSize UI_APPEARANCE_SELECTOR;
- /** Default is UITextFieldViewModeAlways */
- @property (assign, nonatomic) UITextFieldViewMode textFieldsClearButtonMode UI_APPEARANCE_SELECTOR;
- #pragma mark - Callbacks
- /** To avoid retain cycle, do not forget about weak reference to self */
- @property (copy, nonatomic) LGAlertViewHandler willShowHandler;
- /** To avoid retain cycle, do not forget about weak reference to self */
- @property (copy, nonatomic) LGAlertViewHandler didShowHandler;
- /** To avoid retain cycle, do not forget about weak reference to self */
- @property (copy, nonatomic) LGAlertViewHandler willDismissHandler;
- /** To avoid retain cycle, do not forget about weak reference to self */
- @property (copy, nonatomic) LGAlertViewHandler didDismissHandler;
- /** To avoid retain cycle, do not forget about weak reference to self */
- @property (copy, nonatomic) LGAlertViewActionHandler actionHandler;
- /** To avoid retain cycle, do not forget about weak reference to self */
- @property (copy, nonatomic) LGAlertViewHandler cancelHandler;
- /** To avoid retain cycle, do not forget about weak reference to self */
- @property (copy, nonatomic) LGAlertViewHandler destructiveHandler;
- /** To avoid retain cycle, do not forget about weak reference to self */
- @property (copy, nonatomic) LGAlertViewActionHandler didDismissAfterActionHandler;
- /** To avoid retain cycle, do not forget about weak reference to self */
- @property (copy, nonatomic) LGAlertViewHandler didDismissAfterCancelHandler;
- /** To avoid retain cycle, do not forget about weak reference to self */
- @property (copy, nonatomic) LGAlertViewHandler didDismissAfterDestructiveHandler;
- /**
- You can use this block to add some custom animations
- To avoid retain cycle, do not forget about weak reference to self
- */
- @property (copy, nonatomic, nullable) LGAlertViewAnimationsBlock showAnimationsBlock;
- /**
- You can use this block to add some custom animations
- To avoid retain cycle, do not forget about weak reference to self
- */
- @property (copy, nonatomic, nullable) LGAlertViewAnimationsBlock dismissAnimationsBlock;
- #pragma mark - Delegate
- @property (weak, nonatomic, nullable) id <LGAlertViewDelegate> delegate;
- #pragma mark - Initialization
- - (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
- progressLabelText:(nullable NSString *)progressLabelText
- 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
- progress:(float)progress
- progressLabelText:(nullable NSString *)progressLabelText
- buttonTitles:(nullable NSArray<NSString *> *)buttonTitles
- cancelButtonTitle:(nullable NSString *)cancelButtonTitle
- destructiveButtonTitle:(nullable NSString *)destructiveButtonTitle;
- /** To avoid retain cycle, do not forget about weak reference to self for textFieldsSetupHandler block */
- - (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;
- + (nonnull instancetype)alertViewWithTitle:(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)alertViewWithViewAndTitle:(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)alertViewWithActivityIndicatorAndTitle:(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)alertViewWithProgressViewAndTitle:(nullable NSString *)title
- message:(nullable NSString *)message
- style:(LGAlertViewStyle)style
- progress:(float)progress
- progressLabelText:(nullable NSString *)progressLabelText
- buttonTitles:(nullable NSArray<NSString *> *)buttonTitles
- cancelButtonTitle:(nullable NSString *)cancelButtonTitle
- destructiveButtonTitle:(nullable NSString *)destructiveButtonTitle;
- + (nonnull instancetype)alertViewWithTextFieldsAndTitle:(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;
- #pragma mark -
- /** To avoid retain cycle, do not forget about weak reference to self for actionHandler, cancelHandler and destructiveHandler blocks */
- - (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
- actionHandler:(LGAlertViewActionHandler)actionHandler
- cancelHandler:(LGAlertViewHandler)cancelHandler
- destructiveHandler:(LGAlertViewHandler)destructiveHandler;
- /** To avoid retain cycle, do not forget about weak reference to self for actionHandler, cancelHandler and destructiveHandler blocks */
- - (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
- actionHandler:(LGAlertViewActionHandler)actionHandler
- cancelHandler:(LGAlertViewHandler)cancelHandler
- destructiveHandler:(LGAlertViewHandler)destructiveHandler;
- /** To avoid retain cycle, do not forget about weak reference to self for actionHandler, cancelHandler and destructiveHandler blocks */
- - (nonnull instancetype)initWithActivityIndicatorAndTitle:(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
- actionHandler:(LGAlertViewActionHandler)actionHandler
- cancelHandler:(LGAlertViewHandler)cancelHandler
- destructiveHandler:(LGAlertViewHandler)destructiveHandler;
- /** To avoid retain cycle, do not forget about weak reference to self for actionHandler, cancelHandler and destructiveHandler blocks */
- - (nonnull instancetype)initWithProgressViewAndTitle:(nullable NSString *)title
- message:(nullable NSString *)message
- style:(LGAlertViewStyle)style
- progress:(float)progress
- progressLabelText:(nullable NSString *)progressLabelText
- buttonTitles:(nullable NSArray<NSString *> *)buttonTitles
- cancelButtonTitle:(nullable NSString *)cancelButtonTitle
- destructiveButtonTitle:(nullable NSString *)destructiveButtonTitle
- actionHandler:(LGAlertViewActionHandler)actionHandler
- cancelHandler:(LGAlertViewHandler)cancelHandler
- destructiveHandler:(LGAlertViewHandler)destructiveHandler;
- /** To avoid retain cycle, do not forget about weak reference to self for textFieldsSetupHandler, actionHandler, cancelHandler and destructiveHandler blocks */
- - (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
- actionHandler:(LGAlertViewActionHandler)actionHandler
- cancelHandler:(LGAlertViewHandler)cancelHandler
- destructiveHandler:(LGAlertViewHandler)destructiveHandler;
- /** To avoid retain cycle, do not forget about weak reference to self for actionHandler, cancelHandler and destructiveHandler blocks */
- + (nonnull instancetype)alertViewWithTitle:(nullable NSString *)title
- message:(nullable NSString *)message
- style:(LGAlertViewStyle)style
- buttonTitles:(nullable NSArray<NSString *> *)buttonTitles
- cancelButtonTitle:(nullable NSString *)cancelButtonTitle
- destructiveButtonTitle:(nullable NSString *)destructiveButtonTitle
- actionHandler:(LGAlertViewActionHandler)actionHandler
- cancelHandler:(LGAlertViewHandler)cancelHandler
- destructiveHandler:(LGAlertViewHandler)destructiveHandler;
- /** To avoid retain cycle, do not forget about weak reference to self for actionHandler, cancelHandler and destructiveHandler blocks */
- + (nonnull instancetype)alertViewWithViewAndTitle:(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
- actionHandler:(LGAlertViewActionHandler)actionHandler
- cancelHandler:(LGAlertViewHandler)cancelHandler
- destructiveHandler:(LGAlertViewHandler)destructiveHandler;
- /** To avoid retain cycle, do not forget about weak reference to self for actionHandler, cancelHandler and destructiveHandler blocks */
- + (nonnull instancetype)alertViewWithActivityIndicatorAndTitle:(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
- actionHandler:(LGAlertViewActionHandler)actionHandler
- cancelHandler:(LGAlertViewHandler)cancelHandler
- destructiveHandler:(LGAlertViewHandler)destructiveHandler;
- /** To avoid retain cycle, do not forget about weak reference to self for actionHandler, cancelHandler and destructiveHandler blocks */
- + (nonnull instancetype)alertViewWithProgressViewAndTitle:(nullable NSString *)title
- message:(nullable NSString *)message
- style:(LGAlertViewStyle)style
- progress:(float)progress
- progressLabelText:(nullable NSString *)progressLabelText
- buttonTitles:(nullable NSArray<NSString *> *)buttonTitles
- cancelButtonTitle:(nullable NSString *)cancelButtonTitle
- destructiveButtonTitle:(nullable NSString *)destructiveButtonTitle
- actionHandler:(LGAlertViewActionHandler)actionHandler
- cancelHandler:(LGAlertViewHandler)cancelHandler
- destructiveHandler:(LGAlertViewHandler)destructiveHandler;
- /** To avoid retain cycle, do not forget about weak reference to self for textFieldsSetupHandler, actionHandler, cancelHandler and destructiveHandler blocks */
- + (nonnull instancetype)alertViewWithTextFieldsAndTitle:(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
- actionHandler:(LGAlertViewActionHandler)actionHandler
- cancelHandler:(LGAlertViewHandler)cancelHandler
- destructiveHandler:(LGAlertViewHandler)destructiveHandler;
- #pragma mark -
- - (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
- delegate:(nullable id<LGAlertViewDelegate>)delegate;
- - (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
- delegate:(nullable id<LGAlertViewDelegate>)delegate;
- - (nonnull instancetype)initWithActivityIndicatorAndTitle:(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
- delegate:(nullable id<LGAlertViewDelegate>)delegate;
- - (nonnull instancetype)initWithProgressViewAndTitle:(nullable NSString *)title
- message:(nullable NSString *)message
- style:(LGAlertViewStyle)style
- progress:(float)progress
- progressLabelText:(nullable NSString *)progressLabelText
- buttonTitles:(nullable NSArray<NSString *> *)buttonTitles
- cancelButtonTitle:(nullable NSString *)cancelButtonTitle
- destructiveButtonTitle:(nullable NSString *)destructiveButtonTitle
- delegate:(nullable id<LGAlertViewDelegate>)delegate;
- /** To avoid retain cycle, do not forget about weak reference to self for textFieldsSetupHandler block */
- - (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
- delegate:(nullable id<LGAlertViewDelegate>)delegate;
- + (nonnull instancetype)alertViewWithTitle:(nullable NSString *)title
- message:(nullable NSString *)message
- style:(LGAlertViewStyle)style
- buttonTitles:(nullable NSArray<NSString *> *)buttonTitles
- cancelButtonTitle:(nullable NSString *)cancelButtonTitle
- destructiveButtonTitle:(nullable NSString *)destructiveButtonTitle
- delegate:(nullable id<LGAlertViewDelegate>)delegate;
- + (nonnull instancetype)alertViewWithViewAndTitle:(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
- delegate:(nullable id<LGAlertViewDelegate>)delegate;
- + (nonnull instancetype)alertViewWithActivityIndicatorAndTitle:(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
- delegate:(nullable id<LGAlertViewDelegate>)delegate;
- + (nonnull instancetype)alertViewWithProgressViewAndTitle:(nullable NSString *)title
- message:(nullable NSString *)message
- style:(LGAlertViewStyle)style
- progress:(float)progress
- progressLabelText:(nullable NSString *)progressLabelText
- buttonTitles:(nullable NSArray<NSString *> *)buttonTitles
- cancelButtonTitle:(nullable NSString *)cancelButtonTitle
- destructiveButtonTitle:(nullable NSString *)destructiveButtonTitle
- delegate:(nullable id<LGAlertViewDelegate>)delegate;
- /** To avoid retain cycle, do not forget about weak reference to self for textFieldsSetupHandler block */
- + (nonnull instancetype)alertViewWithTextFieldsAndTitle:(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
- delegate:(nullable id<LGAlertViewDelegate>)delegate;
- #pragma mark -
- - (void)showAnimated:(BOOL)animated completionHandler:(LGAlertViewCompletionHandler)completionHandler;
- - (void)showAnimated;
- - (void)show;
- - (void)dismissAnimated:(BOOL)animated completionHandler:(LGAlertViewCompletionHandler)completionHandler;
- - (void)dismissAnimated;
- - (void)dismiss;
- - (void)transitionToAlertView:(nonnull LGAlertView *)alertView completionHandler:(LGAlertViewCompletionHandler)completionHandler;
- - (void)transitionToAlertView:(nonnull LGAlertView *)alertView;
- - (void)setProgress:(float)progress progressLabelText:(nullable NSString *)progressLabelText;
- - (void)setButtonPropertiesAtIndex:(NSUInteger)index handler:(void(^ _Nonnull)(LGAlertViewButtonProperties * _Nonnull properties))handler;
- - (void)setButtonEnabled:(BOOL)enabled atIndex:(NSUInteger)index;
- - (BOOL)isButtonEnabledAtIndex:(NSUInteger)index;
- - (void)layoutValidateWithSize:(CGSize)size;
- - (void)forceCancel;
- - (void)forceDestructive;
- - (void)forceActionAtIndex:(NSUInteger)index;
- #pragma mark - Unavailable
- - (nonnull instancetype)init __attribute__((unavailable("use \"- initWith...\" instead")));
- + (nonnull instancetype)new __attribute__((unavailable("use \"+ alertViewWith...\" instead")));
- @end
- #pragma mark - Delegate
- @protocol LGAlertViewDelegate <NSObject>
- @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;
- /** You can use this method to add some custom animations */
- - (void)showAnimationsForAlertView:(nonnull LGAlertView *)alertView duration:(NSTimeInterval)duration;
- /** You can use this method to add some custom animations */
- - (void)dismissAnimationsForAlertView:(nonnull LGAlertView *)alertView duration:(NSTimeInterval)duration;
- // DEPRECATED
- - (void)alertView:(nonnull LGAlertView *)alertView buttonPressedWithTitle:(nullable NSString *)title index:(NSUInteger)index
- DEPRECATED_MSG_ATTRIBUTE("use alertView:clickedButtonAtIndex:title: instead");
- - (void)alertViewDestructiveButtonPressed:(nonnull LGAlertView *)alertView
- DEPRECATED_MSG_ATTRIBUTE("use alertViewDidDismissAfterDestructed: instead");
- @end
- #pragma mark - Deprecated
- @interface LGAlertView (Deprecated)
- @property (assign, nonatomic) CGFloat layerShadowOpacity
- DEPRECATED_MSG_ATTRIBUTE("use layerShadowColor alpha component instead");
- - (void)setButtonAtIndex:(NSUInteger)index enabled:(BOOL)enabled
- DEPRECATED_MSG_ATTRIBUTE("use setButtonEnabled:atIndex: instead");
- @end
|