AHKActionSheet.h 4.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 TWS. 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. @property (nonatomic) CGFloat blurRadius UI_APPEARANCE_SELECTOR;
  29. @property (strong, nonatomic) UIColor *blurTintColor UI_APPEARANCE_SELECTOR;
  30. @property (nonatomic) CGFloat blurSaturationDeltaFactor UI_APPEARANCE_SELECTOR;
  31. /// Height of the button (internally it's a `UITableViewCell`).
  32. @property (nonatomic) CGFloat buttonHeight UI_APPEARANCE_SELECTOR;
  33. /// Height of the cancel button.
  34. @property (nonatomic) CGFloat cancelButtonHeight UI_APPEARANCE_SELECTOR;
  35. /// Height separator from cancelButtonHeight and table
  36. @property (nonatomic) CGFloat separatorHeight UI_APPEARANCE_SELECTOR;
  37. /**
  38. * If set, a small shadow (a gradient layer) will be drawn above the cancel button to separate it visually from the other buttons.
  39. * It's best to use a color similar (but maybe with a lower alpha value) to blurTintColor.
  40. * See "Advanced" example in the example project to see it used.
  41. */
  42. /// Boxed (@YES, @NO) boolean value (enabled by default). Isn't supported on iOS 6.
  43. @property (strong, nonatomic) NSNumber *automaticallyTintButtonImages UI_APPEARANCE_SELECTOR;
  44. /// Boxed boolean value. Useful when adding buttons without images (in that case text looks better centered). Disabled by default.
  45. @property (strong, nonatomic) NSNumber *buttonTextCenteringEnabled UI_APPEARANCE_SELECTOR;
  46. /// Color of the separator between buttons.
  47. @property (strong, nonatomic) UIColor *separatorColor UI_APPEARANCE_SELECTOR;
  48. /// Text attributes of the title (passed in initWithTitle: or set via `title` property)
  49. @property (copy, nonatomic) NSDictionary *titleTextAttributes UI_APPEARANCE_SELECTOR;
  50. @property (copy, nonatomic) NSDictionary *buttonTextAttributes UI_APPEARANCE_SELECTOR;
  51. @property (copy, nonatomic) NSDictionary *disableButtonTextAttributes UI_APPEARANCE_SELECTOR;
  52. @property (copy, nonatomic) NSDictionary *destructiveButtonTextAttributes UI_APPEARANCE_SELECTOR;
  53. @property (copy, nonatomic) NSDictionary *encryptedButtonTextAttributes UI_APPEARANCE_SELECTOR;
  54. @property (copy, nonatomic) NSDictionary *cancelButtonTextAttributes UI_APPEARANCE_SELECTOR;
  55. /// Duration of the show/dismiss animations. Defaults to 0.5.
  56. @property (nonatomic) NSTimeInterval animationDuration UI_APPEARANCE_SELECTOR;
  57. /// Boxed boolean value. Enables/disables control hiding with pan gesture. Enabled by default.
  58. @property (strong, nonatomic) NSNumber *cancelOnPanGestureEnabled UI_APPEARANCE_SELECTOR;
  59. /// Boxed boolean value. Enables/disables control hiding when tapped on empty area. Disabled by default.
  60. @property (strong, nonatomic) NSNumber *cancelOnTapEmptyAreaEnabled UI_APPEARANCE_SELECTOR;
  61. /// A handler called on every type of dismissal (tapping on "Cancel" or swipe down or flick down).
  62. @property (strong, nonatomic) AHKActionSheetHandler cancelHandler;
  63. @property (copy, nonatomic) NSString *cancelButtonTitle;
  64. /// String to display above the buttons.
  65. @property (copy, nonatomic) NSString *title;
  66. /// View to display above the buttons (only if the title isn't set).
  67. @property (strong, nonatomic) UIView *headerView;
  68. /// Window visible before the actionSheet was presented.
  69. @property (weak, nonatomic, readonly) UIWindow *previousKeyWindow;
  70. /// View actionSheet was presented.
  71. @property (nonatomic, weak) UIView *view;
  72. - (instancetype)initWithView:(UIView *)view title:(NSString *)title;
  73. - (void)addButtonWithTitle:(NSString *)title image:(UIImage *)image backgroundColor:(UIColor *)backgroundColor height:(CGFloat)height type:(AHKActionSheetButtonType)type handler:(AHKActionSheetHandler)handler;
  74. /// Displays the action sheet.
  75. - (void)show;
  76. /// Dismisses the action sheet with an optional animation.
  77. - (void)dismissAnimated:(BOOL)animated;
  78. @end