AHKActionSheet.h 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //
  2. // AHKActionSheet.h
  3. // AHKActionSheetExample
  4. //
  5. // Created by Arkadiusz on 08-04-14.
  6. // Copyright (c) 2014 Arkadiusz Holko. All rights reserved.
  7. //
  8. // Modify by Marino Faggiana on 11/01/17.
  9. // Copyright (c) 2017 Marino Faggiana. All rights reserved.
  10. //
  11. // Author Marino Faggiana <m.faggiana@twsweb.it>
  12. //
  13. #import <UIKit/UIKit.h>
  14. typedef NS_ENUM(NSInteger, AHKActionSheetButtonType) {
  15. AHKActionSheetButtonTypeDefault = 0,
  16. AHKActionSheetButtonTypeDisabled,
  17. AHKActionSheetButtonTypeDestructive,
  18. AHKActionSheetButtonTypeEncrypted
  19. };
  20. @class AHKActionSheet;
  21. typedef void(^AHKActionSheetHandler)(AHKActionSheet *actionSheet);
  22. /// A block-based alternative to the `UIAlertView`.
  23. @interface AHKActionSheet : UIView <UIAppearanceContainer>
  24. // Appearance - all of the following properties should be set before showing the action sheet. See `+initialize` to learn the default values of all properties.
  25. /**
  26. * See UIImage+AHKAdditions.h/.m to learn how these three properties are used.
  27. */
  28. /// Height of the button (internally it's a `UITableViewCell`).
  29. @property (nonatomic) CGFloat buttonHeight UI_APPEARANCE_SELECTOR;
  30. /// Height of the cancel button.
  31. @property (nonatomic) CGFloat cancelButtonHeight UI_APPEARANCE_SELECTOR;
  32. /// Height separator from cancelButtonHeight and table
  33. @property (nonatomic) CGFloat separatorHeight UI_APPEARANCE_SELECTOR;
  34. /**
  35. * If set, a small shadow (a gradient layer) will be drawn above the cancel button to separate it visually from the other buttons.
  36. * It's best to use a color similar (but maybe with a lower alpha value) to blurTintColor.
  37. * See "Advanced" example in the example project to see it used.
  38. */
  39. /// Boxed (@YES, @NO) boolean value (enabled by default). Isn't supported on iOS 6.
  40. @property (strong, nonatomic) NSNumber *automaticallyTintButtonImages UI_APPEARANCE_SELECTOR;
  41. /// Boxed boolean value. Useful when adding buttons without images (in that case text looks better centered). Disabled by default.
  42. @property (strong, nonatomic) NSNumber *buttonTextCenteringEnabled UI_APPEARANCE_SELECTOR;
  43. /// Color of the separator between buttons.
  44. @property (strong, nonatomic) UIColor *separatorColor UI_APPEARANCE_SELECTOR;
  45. /// Text attributes of the title (passed in initWithTitle: or set via `title` property)
  46. @property (copy, nonatomic) NSDictionary *buttonTextAttributes UI_APPEARANCE_SELECTOR;
  47. @property (copy, nonatomic) NSDictionary *disableButtonTextAttributes UI_APPEARANCE_SELECTOR;
  48. @property (copy, nonatomic) NSDictionary *destructiveButtonTextAttributes UI_APPEARANCE_SELECTOR;
  49. @property (copy, nonatomic) NSDictionary *encryptedButtonTextAttributes UI_APPEARANCE_SELECTOR;
  50. @property (copy, nonatomic) NSDictionary *cancelButtonTextAttributes UI_APPEARANCE_SELECTOR;
  51. /// Duration of the show/dismiss animations. Defaults to 0.5.
  52. @property (nonatomic) NSTimeInterval animationDuration UI_APPEARANCE_SELECTOR;
  53. /// Boxed boolean value. Enables/disables control hiding with pan gesture. Enabled by default.
  54. @property (strong, nonatomic) NSNumber *cancelOnPanGestureEnabled UI_APPEARANCE_SELECTOR;
  55. /// Boxed boolean value. Enables/disables control hiding when tapped on empty area. Disabled by default.
  56. @property (strong, nonatomic) NSNumber *cancelOnTapEmptyAreaEnabled UI_APPEARANCE_SELECTOR;
  57. /// A handler called on every type of dismissal (tapping on "Cancel" or swipe down or flick down).
  58. @property (strong, nonatomic) AHKActionSheetHandler cancelHandler;
  59. @property (copy, nonatomic) NSString *cancelButtonTitle;
  60. /// String to display above the buttons.
  61. @property (copy, nonatomic) NSString *title;
  62. /// View to display above the buttons (only if the title isn't set).
  63. @property (strong, nonatomic) UIView *headerView;
  64. /// Window visible before the actionSheet was presented.
  65. @property (weak, nonatomic, readonly) UIWindow *previousKeyWindow;
  66. /// View actionSheet was presented.
  67. @property (nonatomic, weak) UIView *view;
  68. /// Extra Bottom Padding for iPhone X
  69. @property CGFloat bottomPadding;
  70. - (instancetype)initWithView:(UIView *)view title:(NSString *)title;
  71. - (void)addButtonWithTitle:(NSString *)title image:(UIImage *)image backgroundColor:(UIColor *)backgroundColor height:(CGFloat)height type:(AHKActionSheetButtonType)type handler:(AHKActionSheetHandler)handler;
  72. /// Displays the action sheet.
  73. - (void)show;
  74. /// Dismisses the action sheet with an optional animation.
  75. - (void)dismissAnimated:(BOOL)animated;
  76. @end