SCLButton.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. //
  2. // SCLButton.h
  3. // SCLAlertView
  4. //
  5. // Created by Diogo Autilio on 9/26/14.
  6. // Copyright (c) 2014-2017 AnyKey Entertainment. All rights reserved.
  7. //
  8. #if defined(__has_feature) && __has_feature(modules)
  9. @import UIKit;
  10. #else
  11. #import <UIKit/UIKit.h>
  12. #endif
  13. @class SCLTimerDisplay;
  14. @interface SCLButton : UIButton
  15. typedef void (^SCLActionBlock)(void);
  16. typedef BOOL (^SCLValidationBlock)(void);
  17. typedef NSDictionary* (^CompleteButtonFormatBlock)(void);
  18. typedef NSDictionary* (^ButtonFormatBlock)(void);
  19. // Action Types
  20. typedef NS_ENUM(NSInteger, SCLActionType)
  21. {
  22. SCLNone,
  23. SCLSelector,
  24. SCLBlock
  25. };
  26. /** Set button action type.
  27. *
  28. * Holds the button action type.
  29. */
  30. @property SCLActionType actionType;
  31. /** Set action button block.
  32. *
  33. * TODO
  34. */
  35. @property (copy, nonatomic) SCLActionBlock actionBlock;
  36. /** Set Validation button block.
  37. *
  38. * Set one kind of validation and keeps the alert visible until the validation is successful
  39. */
  40. @property (copy, nonatomic) SCLValidationBlock validationBlock;
  41. /** Set Complete button format block.
  42. *
  43. * Holds the complete button format block.
  44. * Support keys : backgroundColor, borderWidth, borderColor, textColor
  45. */
  46. @property (copy, nonatomic) CompleteButtonFormatBlock completeButtonFormatBlock;
  47. /** Set button format block.
  48. *
  49. * Holds the button format block.
  50. * Support keys : backgroundColor, borderWidth, borderColor, textColor
  51. */
  52. @property (copy, nonatomic) ButtonFormatBlock buttonFormatBlock;
  53. /** Set SCLButton color.
  54. *
  55. * Set SCLButton color.
  56. */
  57. @property (strong, nonatomic) UIColor *defaultBackgroundColor UI_APPEARANCE_SELECTOR;
  58. /** Set Target object.
  59. *
  60. * Target is an object that holds the information necessary to send a message to another object when an event occurs.
  61. */
  62. @property id target;
  63. /** Set selector id.
  64. *
  65. * A selector is the name used to select a method to execute for an object,
  66. * or the unique identifier that replaces the name when the source code is compiled.
  67. */
  68. @property SEL selector;
  69. /** Parse button configuration
  70. *
  71. * Parse ButtonFormatBlock and CompleteButtonFormatBlock setting custom configuration.
  72. * Set keys : backgroundColor, borderWidth, borderColor, textColor
  73. */
  74. - (void)parseConfig:(NSDictionary *)buttonConfig;
  75. /** Set button timer.
  76. *
  77. * Holds the button timer, if present.
  78. */
  79. @property (strong, nonatomic) SCLTimerDisplay *timer;
  80. /** Init method
  81. *
  82. */
  83. - (instancetype)initWithWindowWidth:(CGFloat)windowWidth;
  84. /** Adjust width of the button according to the width of the alert and
  85. * the number of buttons. Only used when buttons are horizontally aligned.
  86. *
  87. * @param windowWidth The width of the alert.
  88. * @param numberOfButtons The number of buttons in the alert.
  89. */
  90. - (void)adjustWidthWithWindowWidth:(CGFloat)windowWidth numberOfButtons:(NSUInteger)numberOfButtons;
  91. @end